Why does the fc command bring up this weird file in nano?

C

CrazedNerd

Guest
ive been playing with built in commands. Fc is supposed to execute a command in your history, which it does, but it brings you into nano with this file:

/tmp/bash-fc.eKJwSQ

The command i was trying to is at the top of the document. Does anyone understand this?
 


Yes. If you use fc with no parameters, it will bring up the last command you entered, in a temporary file, in a text editor. Allowing you to edit the command you previously entered.
After changing the command and saving and quitting the editor, the edited command will then be ran.

This is especially useful if you entered a long command and wanted to run it again, but with slightly different parameters.

You can also use -s flag to searh for a recent command.

E.g.
Bash:
fc -s gcc
Would search your bash history for the most recent gcc command you entered and would open it in a text editor, so you could edit it and re-run it.

If memory serves, the editor used by fc is defined in the environment variable $FSEDIT. If $FSEDIT doesn’t exist/is empty, it falls back to use whatever is set in $EDITOR. If $EDITOR is empty, it falls back to use vi (which nowadays is actually vim-minimal running in "compatible" mode, which emulates classic vi).

More and more distro’s currently use nano as the default terminal based editor. But many still have vi/vim-minimal installed too.

I’m guessing your distro uses nano as its default editor. So that is why your last command was opened in a file in nano.
 
Yes. If you use fc with no parameters, it will bring up the last command you entered, in a temporary file, in a text editor. Allowing you to edit the command you previously entered.
After changing the command and saving and quitting the editor, the edited command will then be ran.

This is especially useful if you entered a long command and wanted to run it again, but with slightly different parameters.

You can also use -s flag to searh for a recent command.

E.g.
Bash:
fc -s gcc
Would search your bash history for the most recent gcc command you entered and would open it in a text editor, so you could edit it and re-run it.

If memory serves, the editor used by fc is defined in the environment variable $FSEDIT. If $FSEDIT doesn’t exist/is empty, it falls back to use whatever is set in $EDITOR. If $EDITOR is empty, it falls back to use vi (which nowadays is actually vim-minimal running in "compatible" mode, which emulates classic vi).

More and more distro’s currently use nano as the default terminal based editor. But many still have vi/vim-minimal installed too.

I’m guessing your distro uses nano as its default editor. So that is why your last command was opened in a file in nano.
this clarifies a lot, however, i did it like this:

fc 397

where the argument was the number of the command in history.
 

Members online


Latest posts

Top