Friday, April 3, 2009

split a file in 2 with sed...

If you need to split a file around a line containing special text (lets say "hello world") you shoud do it with sed!

If your file is original.txt, you can do it like this:

sed '1,/^hello world$/!d' < original.txt > first_half.txt
sed '1,/^hello world$/d' < original.txt > second_hald.txt

just simple sed...

hope you like it

1 comment:

  1. Cool...I liked it.

    How can I include hello world in the second_half.txt?

    ReplyDelete