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!

sed - delete and output deleted lines to a new file 2

Status
Not open for further replies.

Autosys

Programmer
Jun 1, 2004
90
GB
Hi there I was hoping that someone could help me.

I would like to do the following:

I have a file called "test" which has the below lines in it:

test test test test 2000
test test test 1000 test
test test 2000 2000 2000
test test test test test

I would like to run the sed command against this file. The command should delete all the lines in the file containing 2000 and output the complete deleted lines into a new file called new_test.

Any help would be fantastic thanks!

S
 
Thanks it it's complaining saying illegal option -i but I assume it's probably the version of UNIX (Linux) I'm using.

thanks for the post! S
 
A one run way with awk:
Code:
awk '/2000/{print>"new_test";next}1' test > tmp_test && mv tmp_test test

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks to both of you guys they appear to work! S
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top