Thursday, May 7, 2009

Cheat code: Short commands

We all use the same commands in quick succession very often. Right? For example, in UNIX lab, I can't tell you how irritating it is to keep compiling and executing the same file over and over again.
$gcc file.c
$./a.out

After typing this once, if we type
$!g
$!.
the shell executes the previously said set of command.

What happens is that if we write "!" followed by a letter, the shell searches your history and executes the last command starting with the letter.
Powered By Blogger