With PHPExcel,I want to generate a file with protection on some cells like
($sheet->getStyle('D' . $row . ':D' . $endrow)->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_PROTECTED);)
but I want to let the right to copy and paste the line to another line.
Can you help please?
Related
trying to create a file with following data using shell script.
InsertParam.sh
echo "$$Domain=XYZ" >parameter.prm
when i run InsertParam.sh
Am getting out put as
$cat parameter.prm
1979205Domain=XYZ
Please help me how to over come this in my parameter.prm
i need Data as
$$Domain=xyz
In sh/bash/ksh/zsh, $$ is the current PID. see https://www.gnu.org/software/bash/manual/bashref.html#Special-Parameters
You need to use different quotes to prevent that variable from being expanded:
echo '$$Domain=XYZ' >parameter.prm
see https://www.gnu.org/software/bash/manual/bashref.html#Quoting
Quotes can be mixed, as required:
echo '$$Domain='"$domain" >parameter.prm
I wanted to write a command that would help me fetch recursively in a folder all filenames that have a particular text in them . Suppose my folder contains lot of files two of them being largest_pallindrome_subsequence_1.cpp and largest_pallindrome_subsequence_2.cpp . Now I want to find files which have sub in it . So the search should return me these 2 cpp files as mentioned above.
The thing is that I also want to look for a file with particular extension say .txt or .cpp .
I tried using grep --include=\*{.cpp} -rnw . -e "sub" but this doesnot work for me.
You can do:
find ./ -name "*sub*"
or:
find ./ | grep "sub"
I have a text file containing filenames of 1300 files:
mmjr0_si2166.wav
mesd0_si1002.wav
mjes0_sx214.wav
mjln0_si819.wav
mkcl0_si1721.wav
.
.
.
mjth0_sx216.wav
how can I edit the filenames in UNIX so that instead of their names, each line shows their paths? I mean something like this:
/Users/Desktop/TIMIT_wav/mmjr0_si2166.wav
/Users/Desktop/TIMIT_wav/mesd0_si1002.wav
/Users/Desktop/TIMIT_wav/mjes0_sx214.wav
/Users/Desktop/TIMIT_wav/mjln0_si819.wav
/Users/Desktop/TIMIT_wav/mkcl0_si1721.wav
.
.
.
/Users/Desktop/TIMIT_wav/mjth0_sx216.wav
sed -i -e 's;^;/Users/Desktop/TIMIT_wav/;' file_with_filenames.txt
Which will make substitution (s/from/to/) of the beginning of line (^) with desired path (/Users/Desktop/TIMIT_wav/).
When I use ls . (/bin/ls) it returns a list of files.
when "." has directories and I try to redirect ls . by ls . > tmp.txt,
it contains many symbols like below
[1m[36m010202E[39;49m[0m
[1m[36m031403C[39;49m[0m
Directory names are 010202E and 031403C
this txt file can be read by "less" but not by vi or any other editors like text wrangler .
How can I avoid this problem?
I know there is a way to delete those characters after making "tmp.txt".
It is likely that there's an alias that makes ls print the output with color. Try to use "ls --color=none", instead.
I am taking a intro to Unix class and am stuck on the final assignment. I need to write a script to change the file extension of a filename that is input when the script is run. The new file extension is also input when the script is run. The script is call chExt1.sh . Our first trial of the script is run as follows
./chExt1.sh cpp aardvark.CPP
The script is suppose to change the second input file extension to the file extension given in the first input. It is not suppose to matter what file extension is given with the file name or what file extension is given as the new extension, nor is it only for changing uppercase to lowercase. In hope to make this very clear if given the following:
./chExt1.sh istink helpme.plEaSe
The script would change helpme.plEaSe to helpme.istink . I have searched on this forum and in google and have had no look with trying the different examples I found. Below is some of the examples I have tried and what I currently have.
Current
#!/bin/sh
fileExtension="$1"
shift
oldName="$2"
shift
newName=${oldName%%.*}${fileExtension}
echo $newName
The echo is just to see if it works, and if I get it working I'm going to add an mv to save it.
Others that I have tried:
newName=`${oldName%.*}`
newName=`${oldName#.*}`
sed 's/\.*//' $oldName > $newName
I can't seem to find some of the other sed I have used but they involved alot of backslashes and () with .* in there. I did not try the basename command cause I don't know the file extension to be entered and all I the examples I saw required that you specify what you wanted removed and I can't. I did not list all the different quote variations that I used but I have tried alot. My instructions say to use the sed command since we should know how to use that from class but when I try to do it I don't isolate just the ending of the file and I believe (cause it takes so long to finish) that it is going through the whole file and looking for .'s and anything after cause I kept doing .* as the pattern. Thanks for anyhelp you can give.
shift shifts the positional parameters, so after calling shift the second parameter ($2) is now the first ($1). The second shift is not necessary, because you are done accessing the parameters. You need to either remove the shift
#!/bin/sh
fileExtension="$1"
oldName="$2"
newName=${oldName%%.*}${fileExtension}
echo $newName
or change $2 to $1.
#!/bin/sh
fileExtension="$1"
shift
oldName="$1"
newName=${oldName%%.*}${fileExtension}
echo $newName
However, you are still missing a dot from your new file name. That is left as an exercise for the reader.