The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 10-13-2008
gugs gugs is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 44
Why does this not work?

I have taken the above example and developed a small test script as shown below to do what I want:

NEXT=TEST01
dir='C:/cygwin/var/log/img/aut/'
cmd1="sed -n '/"
echo $cmd1
cmd2=".*\.mqsc$/{p;q}'"
echo $cmd2
echo "$cmd1$NEXT$cmd2" > command.txt
command=$(grep sed command.txt)
ls -1t $dir | grep $NEXT > temp.txt
filename=$($command < temp.txt)

The results I get when I run the script are:
+ NEXT=TEST01
+ dir=C:/cygwin/var/log/img/aut/
+ cmd1='sed -n '\''/'
+ echo sed -n ''\''/'
sed -n '/
+ cmd2='.*\.mqsc$/{p;q}'\'''
+ echo '.*\.mqsc$/{p;q}'\'''
.*\.mqsc$/{p;q}'
+ echo 'sed -n '\''/TEST01.*\.mqsc$/{p;q}'\'''
++ grep sed command.txt
+ command='sed -n '\''/TEST01.*\.mqsc$/{p;q}'\'''
+ ls -1t C:/cygwin/var/log/img/aut/
+ grep TEST01
++ sed -n ''\''/TEST01.*\.mqsc$/{p;q}'\'''
sed: -e expression #1, char 1: unknown command: `''
+ filename=