Nick W wrote:
On Wednesday 01 June 2005 16:02, William Astle wrote:

Nick W wrote:

On Wednesday 01 June 2005 15:54, William Astle wrote:

Nick W wrote:

because I'm lazy, how would one write a script to recursively rm files
ending in '~' starting at any given dir?

find $dir -type f -name \*~ -exec rm -f \{\} \;

Wow, that was quick. TY for assisting my laziness.

Nick

Some of us have a store of incantations in our heads. And camp on our
email. :)


if you're bored I'd be interested in a syntax explanation. Most of it seems obvious except -f \{\} \;

With "find", {} is replaced with the filename and ; is the indicator of the end of the command specified for -exec. So if "find" has the file "./foo", the -exec would cause

rm -f ./foo

to be executed. The \ characters merely protect the {, }, and ; from whatever shell you're using so it doesn't interpret them.

Basically, that whole find command can be thought of as saying:

For every file name in the tree that is a regular file (-type f) and whose name ends in ~ (-name \*~), remove that file (-exec...).

--
William Astle
finger [EMAIL PROTECTED] for further information

Geek Code V3.12: GCS/M/S d- s+:+ !a C++ UL++++$ P++ L+++ !E W++ !N w---
!D !M PS PE V-- Y+ PGP t+@ 5++ X !R tv+@ b+++@ !DI D? G e++ h+ y?

_______________________________________________
clug-talk mailing list
[email protected]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca
Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
**Please remove these lines when replying

Reply via email to