The !find command lets the user perform the previously executed find, with all its parameters.

How does it work internally, where exactly has this behaviour been programmed?


It's not related to the find command itself, it's a feature of the shell called history expansion. If your shell supports history expansion, you can refer to a past command you typed and do some things with it.

For example in Bash, your action refers to a command from history by an event designator. From the Bash manual:

An event designator is a reference to a command line entry in the history list. Unless the reference is absolute, events are relative to the current position in the history list.


Start a history substitution, except when followed by a space, tab, the end of the line, = or ( (when the extglob shell option is enabled using the shopt builtin).


Refer to the most recent command preceding the current position in the history list starting with string.

For the real internals you can read the source code of get_history_event from Bash 4.3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.