Reputation: 2796
I'm currently pawing through a Unix tutorial and I've been met with this:
find ~ -name test3* -ok rm {}\;
I'm curious as to what the {}\;
does.
Upvotes: 1
Views: 170
Reputation: 26210
The {}\;
string tells find(1) that (a) the file name is to be substituted in place of the {}
, and (b) that the commands ends at the ";". The ";" has to be escaped (hence the backslash) because it has special meaning to the shell. For that same reason, you really ought to quote the 'test3*' string. You want find to expand that, not the shell. If there happen to be matching files in the directory where you run find, you're not going to get the results you expect.
Thus, you're telling find(1) to run "rm" on every file it finds.
There's a more efficient solution to that particular problem, though:
find . -name 'test3*' -print | xargs rm -f
Upvotes: 7