Shell (unix) commands you always forget
This is a list of typical commands that I often have to Google because I forget either their usage or important flags.
grep with perl type regex
-P flag lets you search for more advanced regex expressions. Other useful grep flags:
-oprint only matching
-A numbershow lines after match
-B numbershow lines before match
grep without pipe
searches after pattern
hell\w in current directory and sub-directories. Add
-h to ignore filenames in output.
For loops - range
For loops - command
Bash script for traversing arguments and line breaks
Search and replace file content:
From pipe and print result:
To replace matched regex groups, use \1, \2 and so on.
Finding size of subfolders, sorted.
du -h d -1is the disc usage command with the
-hflag for outputting human readable sizes and
-d 1for depth of 1 sub dirs.
sort -hrsorts human readable sizes in reverse order.