Reputation: 47
I have found this command online, finding and displaying hardlinks to a file e.g. text.txt.
My question: What is the exclamation mark (!) doing in this command?
find $PWD ! -type d -links +1 -ls | sort -n|cut -d" " -f29 | grep --color=auto "$2"
Upvotes: 2
Views: 8614
Reputation: 328556
This negates the next condition. So ! -type d
means "not a directory".
There is one problem, though: !
is also a special character which is used to make bash do history expansion. That's why you often have to escape (... \! ...
) or quote it (... "!" ...
).
See also: The manual for find
(try man find
or info find
).
Upvotes: 6