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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to delete lines

Status
Not open for further replies.

zqadora

Programmer
Nov 13, 2002
10
US
Hello,

I need to delete every empty line in a file. Also, I need to delete the first 10 lines and the last 5 lines in that files regardless if they are empty or not.

Regards,

Ziad
 
#! /bin/ksh -x
# Get the number of lines in the file
FILE=data
typeset -i LINES=`cat $FILE | wc -l`
FIVELESS=`expr $LINES - 5`
sed -e "$FIVELESS,${LINES}d" -e '1,10d' -e '/^$/d' data

-jim
 
awk 'NR>10 && /./ && NR<='$(($(wc -l<file1) - 5))<file1
 
Hello,

I have tried what you suggested and it works. Thanks for all the replies.

Regards,

Ziad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top