Selected Bash shell tricks from Camp CDL breakout group
1. Bash Shell Tips and Tricks
John, Mark, Brian, Michael, Ken, Lisa
2. Interactive shell puzzle 1
You just typed
$ ls –l policy.py stats.py ui_common.py
Count lines of the last file and make a .bak copy of it using
less than 20 keystrokes (no mouse, repeat key counts)
3. Interactive shell answer 1
You just typed
$ ls –l policy.py stats.py ui_common.py
Count lines of the last file and make a .bak copy of it using
less than 20 keystrokes (no mouse, repeat key counts):
$ wc !$
$ cp !$ !$.bak
or
$ cp !${,.bak}
4. Interactive shell puzzle 2
You just typed
$ ls –l policy.py rats.py ui_common.py
Correct rats.py to stats.py using 6 keystrokes (no mouse,
repeat key counts)
5. Interactive shell answer 2
You just typed
$ ls –l policy.py rats.py ui_common.py
Correct rats.py to stats.py using 6 keystrokes (no mouse,
repeat key counts):
$ ^r^st
13. Michael McKinnon’s trick
For Windows users, to dynamically change the
hover over value to reflect the machine you’re
logged into (eg, via Putty):
PROMPT_COMMAND=
'echo -ne "033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}007"'