Linux fc Command
Learn Linux fc Command with examples
Published
- Linux fc Command
- fc Command Syntax
- fc -l Command
- fc -e Command
- fc -n Command
- fc -r Command
- fc command Applications
Linux fc Command
In Linux, we can use “fc” command stands for either “find command” or “fix command”.
fc Command Syntax
>> fc [-e ename] [-lnr] [first] [last]
or
>> fc -s [pat=rep] [command]
fc -l Command
The fc Use to display or execute commands from the history list. Following fc command list the last 10 command.
>> fc -l
To list commands 130 through 150, enter.
>> fc -l {first} {last}
>> fc -l 130 150
To list all commands since the last command beginning with ssh, enter:
>> fc -l | grep ssh
fc -e Command
You can edit commands 1 through 5 using vi text editor, enter:
>> fc -e vi 1 5
fc -n Command
fc -n Command lists the lines along with the line numbers, but in case if you want to list the lines without line numbers you can simply use -n option with -l option as shown below.
>> fc -ln
fc -r Command
fc -r Command can also be used with -l option to just reverse the order of lines i.e newest commands are listed first now as shown below.
>> fc -lr
fc command Applications
- fc command in a way lets you know the command history.
- fc command is the best way to edit the previously entered commands in the case of a minor mistake without re-writing the entire command syntax and argument again.
- It can also be used to list the previously entered commands in the terminal which can be helpful in case you are working with some new commands.