Linux Foo


Repeating Commands

ctrl+p shows the last command, without blindly executing it like !!

ctrl+r for searching your command history (ctrl-r again shows next match)

Find versus Grep

Find searches for filenames and directories

Grep searches within files or directories

Usage:

$ grep word file.txt
$ grep -r word directory

Regex

regex

tr (translate command)

used to substitue or delete a character

for example,

echo 'linux' | tr "[:lower] "[:upper:]"

Sed

sed 's/dog/cat/g' file.txt

replaces dog with cat (syntax is just like vim search and replace).