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
Help for each argument of a shell command: explainshell.com/
1
10
2,336
List only subdirectories of the current directory: ls -d */
1
21
2,815
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,164
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,894
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,346
bash lets you use &> to send stdout and stderr to a file. Version 4 or later.
2
3
13
3,285
'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
The unmount command is umount, no 'n'. Prime candidate for an alias.
1
19
2,793