is a standard program on
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s that lists, edits and reexecutes commands previously entered to an interactive shell. ''fc'' is a
builtin command in the
Bash and
Zsh
The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.
Hist ...
shells and is an
initialism
An acronym is a word or name formed from the initial components of a longer name or phrase. Acronyms are usually formed from the initial letters of words, as in ''NATO'' (''North Atlantic Treaty Organization''), but sometimes use syllables, as ...
for "fix command". It is particularly helpful for editing complex, multi-line commands. The editor can be specified by setting the ''EDITOR'' (changes the default editor) or the ''FCEDIT''
environment variable
An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs. For example, a running process can query the value of the TEMP env ...
.
Examples
Flag
-l
used to list previous command history, with example showing command
ls
as item 1001 in the user's history.
$ fc -l
1001 ls
Flag
-s
with this index would then recall the history command from 1001:
$ fc -s 1001
ls
Though more powerfully,
-s
enables inline substitution.
$ ls floder
ser typo
$ fc -s ^floder^folder^
ls folder
ommand revised and runs with correction
Most powerfully, executing fc on its own ''edits'' the last command executed. Editor can be specified on command line (-e) or via environment variable FCEDIT. User is thus able to fully modify the last command executed via the editor, upon exiting will execute the resultant command.
$ fc
hange 'ls' to 'ls -la' in editor and exitls -la
See also
*
List of Unix commands
This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems.
List
See also
* List of G ...
Solaris manual page for fc command
References
External links
*
Standard Unix programs
Unix SUS2008 utilities
{{unix-stub