I really like this book, even today: http://shop.oreilly.com/product/9780596003302.do
The key to being proficient at the command line (as distinct from writing shell scripts) is to think of it as composition.
For example, run this:
$ file $(which $(man -k python | cut --delimiter " " --fields 1))
(The first '$' is your command line prompt, yours may differ; you don't type that. The other '$' characters you do type.)Now run each command from the inside out, starting with the man command. See what each command does. Build it up bit by bit, that's exactly what I did, like this:
- the man command
- the man command piped into the cut command
- the man command piped into the cut command after reading "man cut" to remember about the --delimiter option
- the output of that pipeline fed to which
- the output of which fed to file
Note that I didn't use any for loops or variables, the shell did the right thing for me.
Read the man pages for each of those commands.
set -o vi or set -o emacs (or their equivalent in .inputrc) helps a lot when you compose things incrementally. esc-k k k (etc) is your friend if you set -o vi.
Read man bash. It will take you a long time. For today, read the section on READLINE. While in man bash, search for the word READLINE at the front of the line, like this:
/^READLINE
Slash = search
^ = anchor the search to the front of the line
READLINE = what you're searching for in the current man page.
For now, all you need in your ~/.inputrc file is:
set editing-mode vi
This will give you vi command line editing in bash, as well as any other program that uses readline, like the python REPL.
For more info on .inputrc,
$ man readline
which is documentation for the C interface to readline, but is mostly about how readline is used by a user. For example, in man readline/VI Mode bindings
gives you all your command line editing commands when you use vi mode.
Get a mostly table of contents of man bash, for your searching pleasure:
$ man -P cat bash |egrep -v "^ " |egrep -o "^[^ ]+"
Sort it: $ man -P cat bash |egrep -v "^ " |egrep -o "^[^ ]+" |sort