Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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).

!string

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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