Sunday, November 18, 2012

Grep tips

To get all lines not beginning with a tab, do
grep -vP "^\t" abc.txt
-P turns on Perl-style regex (otherwise tab cannot be specified as \t). "^\t" matches lines beginning with a tab. -v inverts the selection.

For most cases though, using -E (extended regex) instead of -P works, and is better supported.

Friday, November 16, 2012

Using `less'

View text files using less, including very large files. It also opens gzip-ed files. Use less -S to truncate long lines (instead of wrapping around).