You are not logged in.
I need to combine lines 1-20 and 41-60 of a file into a single stream.
I understand I can pull lines 1-20 with "sed -n 1,20p file.dat"
And I understand I can pull lines 41-60 with "sed -n 41,60p file.dat"
But how can I pull both sections with one command? Any ideas?
Last edited by tony5429 (2009-03-01 04:57:06)
Offline
sed -n '1,20p;41,60p' file.dat
also sed 21,40d unless 60 is not the last, then you'd need a ; construct too.
Offline
You can use something like this. It prints lines 1-3 and 6-10 to test_file.
sed -n -e '1,3p' -e '6,10p' file.dat > test_file
Offline
Sed is a simply amazing tool. Thanks for the help - it works fine now.
Offline