Archives for January, 2011

31
Jan

Delete Lines Within File Containing Matching Pattern/Text

Here’s a quick one-liner command that will remove any lines matching a text patter from a file:

sed -i '/pattern/d' filename

For example, say I want to remove all lines in the file garbage.txt that contain the text “foobar”. Here is my console output.

user@localhost $ cat garbage.txt
This is a plain text file that
contains lots of text
but most of it is foobar
and it's unnecessary
to include foobar in text.

user@localhost$ sed -i '/foobar/d' garbage.txt
user@localhost$ cat garbage.txt
This is a plain text file that
contains lots of text
and it's unnecessary

user@localhost$
28
Jan

Good Comparison of Common Compression Tools

I ran across this page when searching for best compression tool for plain text files. Thought it was well done and good enough to share.

http://blog.terzza.com/linux-compression-comparison-gzip-vs-bzip2-vs-lzma-vs-zip-vs-compress/