Skip to main content

Linux Tips: How To Save a Command for Later

Linux Performance
By Keith Edmunds3 October 2017No Comments

Sometimes, when working at the shell prompt, we can be constructing a long command and then realise we’re not ready to run the command just yet.

We could hit the Home key, type a hash (#) to comment the line, and hit return. That would put the command in the history without running it, and we can recall it later (up arrow) and edit it when we’re ready to run it.

There’s a shortcut for the above: just type Alt-#

Example

Let’s imagine we’ve started to build a command line like this:

before

Then we realise we need to move some files first. At the point we’re at above, we type Alt-#. The display now looks like this:

after

Now we can do whatever we needed to do first, then recall this command, remove the hash and carry on.

Could This Linux Tip be Improved?

Let us know in the comments below.