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
Can install GNU versions of Unix utilities on Mac with homebrew: brew install coreutils
1
10
1,981
Help for each argument of a shell command: explainshell.com/
1
11
2,719
List only subdirectories of the current directory: ls -d */
1
21
2,826
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,177
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,900
UNIX Style, or cat -v Considered Harmful harmful.cat-v.org/cat-v/
1
1
12
2,719
Better bash scripting in 15 minutes robertmuth.blogspot.com/2012…
1
3
45
5,347
bash lets you use &> to send stdout and stderr to a file. Version 4 or later.
2
3
13
3,286
'If you had done something twice, you are likely to do it again.' -- Brian Kernighan and Rob Pike
2
12
2,733
Using git, add and commit all modified files in one command: git commit -a -m 'commit message'
11
2,696
Rename foo.old to foo.new: mv foo.{old,new} foo.new
1
9
3,018
Create a directory and change into it: mkdir dir && cd $_
1
2
24
2,808