Bash’s FC
I find that not everyone was born using bash, and sometimes people are surprised at some of the little tricks that we old guys have been using for years. Here is one little tip:
Sometimes you have to do something that is just too large for a command line. In some cases, it’s better if you can fire up some editor and make the commands “just right” before firing them.
You can simply type ‘fc’ and (provided you set FCEDIT or EDITOR) you’re immediately editing your last command in your favorite editor.
Better yet, lets say you have a bunch of files you have to manipulate. You can one one of them by hand using the usual trial-and-error technique and then use ‘fc’ to pull it up the successful command in the editor. You can open a separate pane into your directory listing (or in a vim variant you can do “!ls”. Now you can easily repeat all the commands for every other file you need to manipulate. When you exit the editor, your commands will execute as if you just typed them in one-at-a-time. Only much faster.
If the commands to manipulate the first file spans many lines, use the history command to spot the range of lines. If it runs from roughly line 480 to line 520, type ‘fc 480 520′ and then edit out any unwanted lines (syntax errors, etc). You can even save the contents into a separate file to use as a script.

Holy cow! Never knew that was in there. Man, this could have saved me a lot of heartache if I knew about it. Thanks for posting.
-a TFUGer
Comment by Quag7 — 2008-November-10 @ 10:26