Hi,
Can you please help. I am scripting in sh and I am trying to simply copy one directory to another but for some reason my variables are not recognised?
HTML Code:
echo "The latest version of the program is being found......."
cd $SOFTWARE/src/$progname
version=`ls $SOFTWARE/src/$progname | grep 'v00*' | tail -1`
echo "Latest version for $progname is $version"
#Copy over the latest version of the program
cp -r $SOFTWARE/src/$progname/$version $SOFTWARE/devl/$progname
The problem is to do with the $version variable it seems because when I subsitute $version with a directory name that is hard coded it works BUT when you simply echo $version it also looks correct. Do I need to convert it to a different format or something?
I think cabrao meant that you didn't need the *. Besides, with your grep in single quotes the shell would not expand it in any way so it would look for filenames literally including v00*
At the very least in a regular expression you would need .* (without single quotes)
A * in a regular expression matches 0 or more of the last expression (in your case the character 0), whereas . means match any character and .* matches 0 or more of any character.
You should also change your ls to "ls -1".
I don't know the names of the files in your $program directory, but:
should also do the same thing.
Don't confuse the * in how the shell expands filenames with * in a regular expression - they're not the same thing.
okay, these alternatives still work but i am facec with the same problem when trying to do the copy, it seems to find the latest directory or version e.g. v003 but it does not copy the directory to the target directory?
if i hard code v003 in the scrpt instead it works though???
don't get any I'm affraid, i only realise it hasn't copied the directory when looking into the target one and its empty. to confirm the source and target are correct I have echoed these pathnames and they appear correct in the terminal and when I do the same command cp -r source target on the command line it works? by the way I'm on the linux too
In the bash below the variable date displays in the echo. However when I use it in the for loop it does not. Basically, the user inputs a date then that date is converted to the desired format of (month-day-year, no leading 0). That input is used in the for loop to return every file that matches... (5 Replies)
Hello,
I am writing a script which is not giving the desired result. When I check the content of the 'InputFile_009_0.sh', it shows following with missing Index in this command
sed -i "s/L1ITMBLT.root/L1ITMBLT_"".root/g" run_DttfFromCombinedPrimitives_cfg.py
of .
Any help?
... (13 Replies)
I have a script.
#!/bin/sh
cur_$1_modify_time=Hello
echo "cur_$1_modify_time"
When I run like
sh /root/script1 jj
I expect value "Hello" being assigned to variable "cur_jj_modify_time" and output being "Hello" ie echoing $cur_jj_modify_time
But the output comes as
# sh... (3 Replies)
I am having difficulties with the fllowing script:
!/bin/sh
voicemaildir=/var/spool/asterisk/voicemail/$1/$2/INBOX/
echo `date` ':' $voicemaildir >> /var/log/voicemail-notify.log
for audiofile in `ls $voicemaildir/*.wav`; do
transcriptfile=${audiofile/wav/transcript}
... (4 Replies)
Hi everybody,
Currently, I have a script which access a remote computer via SSH, go to a folder already defined in the code and then executes a program in it, just like that:
ssh user@host << EOI
cd path
./file
EOI
It executes fine, but now I want to pass an argument in the command... (2 Replies)
Hi,
I am facing a challenge in fixing an issue in my installation scripts.Here is a situation:
There are 3 files which are invoked at a below given order:
Installer.ksh----->Installer.xml(Ant script)------->common.ksh
I am outputting a message from common.ksh at a terminal, after that trying to... (3 Replies)
Hi,
I have a unix script which can accept n number of parameters .
I can get the parameter count using the following command and assign it to a variable
file_count=$#
Is there a similar command through which i can assign a variable all the values that i have passed as a parameter
... (2 Replies)
Does anybody know how to print a variable passed to awk command?
awk -F"|" 'BEGIN {print $job,"\n","Question \n"} {print $1,$2$4," ",$3}' "job=$job1" file1
I am trying to pass job the variable job1.
the output is blank.
?? (3 Replies)
Anybody know what's wrong with this syntax?
awk -v job="$job" 'BEGIN { FS="|"}
{print $1,$2," ",$4," ",$3\n,$5,"\n"}' list
It's keeping give me this message:
awk: syntax error near line 1
awk: bailing out near line 1
It seems awk has problem with my BEGIN command.
Any... (8 Replies)