ZGainsforth
7/30/2014 - 5:47 AM

List of common terminal commands to do useful things on OS X.

List of common terminal commands to do useful things on OS X.

View network usage by process. Make sure to make the terminal window the width of the full screen (~200 chars wide is good). Press 'd' to switch to delta mode and then every second it reports what was sent in the last second. You can use right and left arrow to see all columns if you can't make the terminal window wide enough.

nettop

Find a file under the current directory matching a wildcard.

find . -name "*.txt"

Find a file matching a name using spotlight

mdfind -name "gcc"

Track disk usage by process. Get 12 samplings each 5 seconds long and list them.

sudo iotop -C 5 12

Kill processes by name (in this case the process name is top.

sudo killall top

Compress a dirctory with 7z:

7z a -mx3 -mmt CoupledSubsOctTetB.7z CoupledSubsOctTetB

mx3 is fast compression, but not super fast.

mmt enables multithreading.

Make a parity archive for rebuilding large files (like 7z) in case of corruption.

par2 create -v CoupledSubsOctTetB.7z

rsync without delete. Don't forget the slashes on the end of the directories!

rsync -avz source/ dest/

rsync with delete.

rsync -avz —delete source/ dest/

Soft link.

ln -s /full/path/to/original/file /full/path/to/link

Reduce resolution of the clipboard image (useful for retina displays)

pngpaste - | convert - -interpolate nearest -filter point -sample 50% - | imgcat

sed replace, -i does it in place.

sed -i 's/DenseScale=1/DenseScale=2/' CNN.py

If you want to change every occurence use:

sed -i 's/DenseScale=1/DenseScale=2/g' CNN.py

Remember the quoted text are regex so gotchas include / \ ' " . & * etc.