On Wed, 2003-10-29 at 15:14, Ross Drummond wrote: > Comments, improvements appreciated
> echo -e "\nType in the name of the file you wish to extract lines from. \nThen > press <ENTER>" > read FileName > > echo -e "Type the number of the line where you want to start.\nThen press > <ENTER>." > read StartNumber > > echo -e "Type the number of the line where you want to finish\nThen press > <ENTER>." > read FinishNumber Style question - aren't unix command line programs supposed to use parameters, rather than interactive prompting? and to read from stdin if no filename is supplied? > if [ ! -f "$FileName" ] > then > echo -e "Error. File does not exist.\nScript terminating." > exit 0 exit 0 means an exit code of 0, which to most programs means "sucessful completion" Perhaps you want exit 1 here and exit 2 below ... > fi > > if [[ $StartNumber -ge $FinishNumber ]] > then > echo -e "Error. Start line number is greater than or equal to finish line > number.\nScript terminating." > exit 0 > fi > > TotalLines=`wc -l $FileName | cut -d \t -f 1` > > if [[ $FinishNumber -gt $TotalLines ]] > then > echo -e "Error. The finish line number is greater than the number of lines in > the file.\nScript terminating." Shouldn't these errors be sent to stderr? else they'll end up in the data > exit 0 > fi > > cat -n $FileName |head -n $FinishNumber | tail -n > $((($FinishNumber-$StartNumber)+1)) >
