Show Menu
Cheatography

Advanced Bash Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Monitoring

watch -n 5 'ntpq -p'
Issue the 'ntpq -p' command every 5 seconds and display output

Filtering

egrep '(Tom|Dan) Savage' file
Print lines contain 'Tom Savage' or 'Dan Savage'
grep -irl 'keyword' *
Print all files name which contains keyword (cas­e-i­nse­nsi­tive, search from current folder recu­rsi­vely )
head -20 file | tail -10
Print lines 11 t0 20 of file

Editing

:put=r­ead­fil­e('­/pa­th/­to/­foo­/fo­o.c­')[2:7]
In vi, read lines 3 to 8 in foo.c and insert the lines to current file after current cursor line
 

Creating

ln -sv target­/ex­ist­ing­/di­rectory new_li­nk_­to_­create
Create a soft link file to existing folder