locate and delete a line from a file
Hi, folks,
How to locate a special line in a file and move it to another file?
I got a fixed length file from mainframe. The file looks like this:
source.txt
-------------------
100 0.1111 0.1111
200 0.2222 0.2222
300 0.3333 0.3333
400 0.4444 0.4444
999 0.9999 0.9999
I wanna split the file into two files with script, the desired output files are supposed to be like:
output1.txt
-------------------
100 0.1111 0.1111
200 0.2222 0.2222
300 0.3333 0.3333
400 0.4444 0.4444
output2.txt
-------------------
999 0.9999 0.9999
We can tell the special line by the first column with a special number like 999. but I don't know how to locate the special line in script, copy it to anohter file before delete it from the source file.
I guess we can do it with sed, awk, etc. but it's been a long time since last time i used them.
Could you shed some light on it?
eilison
Thanks in advance!
|