Simo Kauppi writes: >Not sure if I understood the problem correctly, but how about: > >#! /bin/sh >filechop () { > #This function takes one file at a time and removes the bottom 6 lines. > #Get a single numerical value stating how many lines are in the file. > zlength=`wc -l $zonename|awk '{print $1}'` > shortlength=$(($zlength - 6)) > head -$shortlength $zonename >tmp.zone > mv tmp.zone $zonename > return 0 >} >#main routine >for zonename in `ls *.zone`; do > filechop; >done
It looks like you noticed the real problem. It took me a minute to see what was different between my original script and what you did, but I see that you put a ; after the function call. That makes the shell wait until the call is completed before moving on to the next command. The shell expansion occurred immediately upon executing the script which caused both the arithmetic part of the script and the variable substitution for the file name to break because they got a list of data to process rather than one piece of data at a time which was what I intended to happen. Several others on this list were very close with their helpful suggestions so nobody was wrong, but the ; after calling the function made the script do everything sequencially. This is one of those things that is fairly clear to me, but I don't know when I would have thought of the solution on my own. Thank you all who took the time to respond because each suggestion made me look to see what was the thinking behind that suggestion and I learned a lot from each one. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]