![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what is wrong with this script? | rs1969 | UNIX for Dummies Questions & Answers | 2 | 11-15-2007 07:16 AM |
| What's wrong with this script | amitg1980 | Shell Programming and Scripting | 3 | 11-12-2007 07:00 PM |
| what is wrong with this script? | hankooknara | Shell Programming and Scripting | 8 | 06-09-2007 12:33 PM |
| What is wrong with this script? | heprox | Shell Programming and Scripting | 8 | 11-16-2006 05:43 AM |
| what is wrong with this script? | circleW | Shell Programming and Scripting | 2 | 09-28-2004 08:27 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
What is wrong with my script?
Hey guys, can someone help me with this script...
Code:
#!/bin/sh
dir=`pwd`
for i in *.f
do if [ -f ${i} ]
then M=`wc -l < ${i}
sed -e 's://.*::' < ${i} | \
(echo "//${i} -"$M ; cat - ) > $i.tmp
chmod 700 $i ; mv ${i}.tmp $i
echo $i --- $M
fi
if [ -d $i ]
then cd ${i} ; $HOME/fred_sh ; cd $dir
fi
done 2>> /dev/null
added code tags for readability --oombera Last edited by oombera; 02-19-2004 at 02:57 PM.. |
|
|||||
|
I agree with oombera, if this is homework....get to work! With practice, unix is not that difficult. As for the error, you are missing a backquote in this line then M=`wc -l < ${i}
I didnt really carefully read your script, other than to look at the things oombera pointed out. Need to correct those. What is the point of this block in your script anyway? if [ -d $i ] then cd ${i} ; $HOME/fred_sh ; cd $dir fi |
|
|||||
|
It says there's an error on line 15 because where you have semicolons you are actually placing several lines of code on one line. Your code would be clearer like this:
Code:
01 #!/bin/sh
02 dir=`pwd`
03 for i in *.f
04 do
05 if [ -f ${i} ]
06 then M=`wc -l < ${i}
07 sed -e 's://.*::' < ${i} | \
08 (echo "//${i} -"$M ; cat - ) > $i.tmp
09 chmod 700 $i
10 mv ${i}.tmp $i
11 echo $i --- $M
12 fi
13 if [ -d $i ]
14 then cd ${i}
15 $HOME/fred_sh
16 cd $dir
17 fi
18 done 2>> /dev/null
|
|
||||
|
It's a sintax Error
As my friend google told U there is an error on the line:
then M=`wc -l < ${i} You are missing a backquote. Your whole script is 15 lines at all, so the shell tries to compile the script to the end trying to find the closing backquote. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|