Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove 10 lines at header

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
GB
I need to remove 10 lines at the start of a file, then remove 9 lines at the bottom of the same file.How can I do this ?

Once the header(10 lines) and footer (9 lines) have been removed i then need to append the data within that file to the end of a file before the 9 lined footer !

Hope ive made this clear.
 
kindive sounds like an "assignment". This will get you started.

#!/usr/bin/ksh
FILE=$1
NUM_OF_LINES=`cat $FILE | wc -l`
TAIL_NUM=`expr $NUM_OF_LINES - 10`
HEAD_NUM=`expr $TAIL_NUM - 9`
tail -$TAIL_NUM $FILE | head -$HEAD_NUM

crowe
 
Actually the last line of your script needs to be:

tail +11 $FILE | head -$HEAD_NUM

you see the tail +11 displays the file starting from line 11. That part is NEVER variable. Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top