Here is a summary from the deleting files page.
The most efficient and secure method to delete any file with name ending in '~' in the directory /path is:
find /path -name \*~ -delete
Using command xargs may allow us to achieve same efficiency but is not as secure:
find /path -name \*~ -print0 | xargs -0 /bin/rm
where '-print0' specifies using ASCII NUL to separate the entries in the file list, and similarly '-0' for command xargs.
If the '-delete' action is not available, we may use action '-execdir' or '-exec':
find /path -name \*~ -execdir /bin/rm {} \+
find /path -name \*~ -exec /bin/rm {} \+
Action '-execdir' is secure but less portable. On the other hand, action '-exec' is most efficient portable but insecure. These two actions can be used for doing things other than deleting files.
No comments:
Post a Comment