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

Cut certain lines in a number of files 1

Status
Not open for further replies.

Trancemission

Technical User
Oct 16, 2001
108
GB
I am looking to remove 1 line of text from about 50 zone (ASCII Files) files. The line of text is the same in every file. All the files are in the same directory. The line that I which ti use has a unique text string of mailfix.

I am just starting my UNIX scripting honeymoon but have been flung in at the deep end due to a techie being ill :(

All help would be appriciated.

Marcus
 
OK ... here's one way. You'll need to adapt it a bit though.

for i in `ls file_pattern*`
do
awk '!/mailfix/ {print}' $i > $i.tmp
mv $i.tmp $i
done

Greg.
 
In fact, you don't even need the print statement ...

for i in `ls file_pattern*`
do
  awk '!/mailfix/' $i > $i.tmp
  mv $i.tmp $i
done

Greg.
 
My choice would be to replace the awk line with

egrep -v mailfix $i > $i.tmp

- Steve StevieW85@go.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top