sed

sed is a great command line tool for *nix operating systems.  There's a great tutorial on it here.

I definitely don't use it to it's full potential but it's convenient for stripping parts of a file out.  Say you want to get a part between two key words, use this
sed -e '1,/StartKeyword/ d' -e '/EndKeyword/,$ d' in.txt > out.txt
This command says to delete everything from line 1 to 'StartKeyword' and then to delete everything from 'EndKeyword' to the end of the file '$' and to put it into out.txt.

Alternatively, you can use the ! (not) sign to do the opposite.  For example, say I want to keep everything between lines 1-10 and put that into a file, use this
sed -e '1,10 !d' in.txt > out.txt
So, sed becomes quite convenient for working with large text files, and I haven't even begun to scratch the surface of what it can do.

No comments: