Save previously executed command in a text file


fc – Display or execute commands from the history list.

If you want to save a complex one liner command that you written to text file fc is use full. This is one of application of fc command.


Lets say we are executing a one liner(command) as shown below

$ find | grep “cli-” -i | grep jar

To save above command in a text file just run fc command.

$ fc

It will open a text file with vi editor and adds above command to that file. By default it wont saved, we need to save and exit.


Leave a Reply

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

You are commenting using your 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