Tips on Unix utilities and related topics from @JohnDCook.

Joined August 2011
'The enjoyment of one's tools is an essential ingredient of successful work.' -- Donald E. Knuth
12
331
14
622
You can find the dimensions of a png image using the file command, e.g. file foo.png.
3
2,635
Can install GNU versions of Unix utilities on Mac with homebrew: brew install coreutils
1
12
2,733
Help for each argument of a shell command: explainshell.com/
1
11
2,754
List only subdirectories of the current directory: ls -d */
1
22
2,843
Shell scripts run in their own subshell, so a cd in a script only effects the subshell. To script a cd, use an alias instead.
2
1
30
3,194
Two bash shortcuts to cd into /long/path/name cp file.txt /long/path/name cd !$ cp file.txt /long/path/name/foo.txt cd !$:h The :h modifier is for "head", i.e. strip off the last part of the path.
2
5
42
2,914
UNIX Style, or cat -v Considered Harmful harmful.cat-v.org/cat-v/
1
1
12
2,729
Better bash scripting in 15 minutes robertmuth.blogspot.com/2012…
1
3
45
5,353
bash lets you use &> to send stdout and stderr to a file. Version 4 or later.
2
3
13
3,291
'If you had done something twice, you are likely to do it again.' -- Brian Kernighan and Rob Pike
2
12
2,738
Using git, add and commit all modified files in one command: git commit -a -m 'commit message'
11
2,700
Rename foo.old to foo.new: mv foo.{old,new} foo.new
1
9
3,021