Linux reuse command history with shortcuts

Using command line history effectively will boost your productivity.
Here are some tips:

Repeat last executed command:

$ !!

or

$ !-1

Execute command with a key word:

$ !?wc?

It will run most recently executed command with with key word wc.

Execute last executed command that starts with a key word:

$ !wc

It will run most recently executed command that starts with wc

Execute first command in history file:

$ !1

Execute most recent nth command from history:

$ !-n

where n is number.

Execute line number 10 in the history:

$ !n

where n is number, it will execute command in nth line from command line.

-Sany

About these ads

One comment on “Linux reuse command history with shortcuts

  1. Pingback: Linux bash use arguments of previous command | Sany's Linux and Open Source Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s