Another useful bash thing: !! (which substitutes the last command you entered)
cat /really/long/path/to/something/only/readable/by/root
cat: Permission denied (goddamnit)
sudo !!
cat /really/long/path/to/something/only/readable/by/root
cat: Permission denied (goddamnit)
sudo !!
$ ls /long/path/to/file.ext
$ less !$
bash-3.2$ less /var/log/authd.log.0.gz
"/var/log/authd.log.0.gz" may be a binary file. See it anyway?
bash-3.2$
I type: control-P control-A meta-D zcat control-E | SPACE less bash-3.2$ zcat /var/log/authd.log.0.gz | less
On the OS X terminal, you have to configure it to treat option as meta before the meta-D above will work. I forget whether common Linux terminals require such configuration. (Edit: zless would work just as well here, and on Linux "less" appears to basically have the functionality of zless.) <ESC> k cw zcat <ESC> A <SPACE> | <SPACE> less <CR>
Very natural for any Vi user: go up a "line", change the first word, then append.There are zillions more such that can be done in Unix, of course, if one puts one's mind to it and experiments, even without spending a lot of time. Another simple one I use some is to define some environment variables to the value of long directory names to which I need to go often as part of some project. Then I can just do:
cd $short_name_for_that_dir
A shell alias can also be used instead.