Command-line interface

find

Find files with filename and exec command against them

Delete found files:

$ find ./ -maxdepth 1 -name "8*" -delete
$ find ./ -maxdepth 1 -name "8*" -exec rm {} \;

Move found files:

$ find ./ -maxdepth 1 -name "8*" -exec mv {} tmp/ \;

perl

Perl Pie

$ perl -pi -e '<some replacement regular expression>' <file or files>

grep

Frequently Used Options

-P, --perl-regexp         PATTERN is a Perl regular expression
-H, --with-filename       print the filename for each match
-R, -r, --recursive       equivalent to --directories=recurse
-B, --before-context=NUM  print NUM lines of leading context
-A, --after-context=NUM   print NUM lines of trailing context
-C, --context=NUM         print NUM lines of output context
-i, --ignore-case         ignore case distinctions
$ grep -r -i -P -B 3 -A 3 "orbitz" *

Find duplicate words

The following will print out duplicate words cases such as the the:

$ grep -E "\b(\w+)\b \b\1\b" *.lyx

Searching in all files recursively using grep -r

$ grep -r "ramesh" *

From shell history, find items with rename in it

$ history | grep 'rename'
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.