开发者

Function of {} \;

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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜