Monday, March 9, 2009

Linux fc tips

fc is a command in Linux which I can't seem to remember no matter how many distros I hopped onto.

So I post this as a reminder, as well as for the benefit of anyone who despise reading man pages :)

To list your executed command history:

fc -l


The above will lists the commands with line numbers on the left like so:

492 unrar x some.part1.rar
493 sync;exit
494 python editor_test.py
495 cd Documents/python_editor/
496 vi test.py
497 python test.py


To execute command history number 495 above:

fc -s 495


To edit it before executing however, use the one below.
After you exit the editor, the command will be executed:

fc 495


If you would like to execute the last command with the word 'mailer' in it:

!?mailer?