Show Menu
Cheatography

Bash Cheat Sheet (DRAFT) by

Basic Bash Commands

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

GREP

grep -B n 'string' FILE.txt
Display n lines before matching string
grep -A n 'string' FILE.txt
Display n lines after matching string
grep '.\{10\}' FILE.txt
Select line lines equal or longer than 10 characters
grep -r -i --include \*.vbs "­PAT­TER­N"
Grep for specific file types containing string:

sed

sed -i '/patt­ern/d' FILE.txt
Delete entire line containing a sting
sed -i -e 's/del­ete­thi­s//g' FILE.txt
Delete string from file
sed -i 's/old­-wo­rd/­new­-wo­rd/g' FILE.txt
Replace all occurances of string with another string
sed 's/$/P­ATT­ERN/' 
Append string (PATTERN) at the end of line