Command line essentials
When you’re using the terminal in OS X, you’re usually using BASH, the Bourne-Again Shell. I’m occasionally surprised by long time terminal users who don’t know some of the following tips:
CTRL-A
Jump to the start of the line
CTRL-E
Jump to the end of the line
history
Get a list of the last 500 commands typed
history | grep ssh
Show a list of the last ssh commands you used
!script
Run the last command you typed that began with script… (eg script/server -p 3100 -e production). Use this one with care - !rm can be a dangerous command
`backticks`
Commands in backticks are evaluated first, and the result of the command is inserted into their place in the command. For example:
rm -rf `find . | grep svn`
Removes all the .svn directories from your current directory
CTRL-L
Clear the terminal screen
OPTION-K
Clears the scrollback history (this is an apple terminal command)
OPTION-T
New Tab in the t apple terminal
tail -f log/production.log
Follow a log (like cat, except stays open and displays new lines as they are written to a file)
CTRL-Z
Pause the current process
bg
Put a paused process into the background (same as running ./process &)
fg
Brings a backgrounded process into the foreground again
grep term -B 2
Greps a file for ”term”, then displays the matching line and the two lines before it.
And when you’re working with files directly - these commands work in most versions of less or vim:
CTRL-B
Page down
CTRL-D
Page up
>
Go to end of file
<
Go to start of file
:123
Go to line 123
/searchterm
Searches for said term
If you use the terminal a lot, it’s definitely worth reading the bash reference and the advanced bash scripting guide. It’s one of those cases of a half hour spent reading saving you an hour per week.

July 2nd, 2010 at 10:09 am
Buy:Nymphomax.Female Pink Viagra.Aricept.Lasix.Seroquel.Amoxicillin.Lipothin.Zocor.SleepWell.Lipitor.Acomplia.Benicar.Buspar.Cozaar.Ventolin.Female Cialis.Prozac.Wellbutrin SR.Advair.Zetia….