bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

xargs & find documentation EXAMPLE suggestions


From: Jeff Carr
Subject: xargs & find documentation EXAMPLE suggestions
Date: Mon, 09 Aug 2004 20:22:25 -0500
User-agent: Mozilla Thunderbird 0.7.1 (X11/20040715)

It'd be really good to have some examples in the xargs man & info pages. One thing I've never know the best way to do is:

find . |grep CVS |xargs -n 1 rm -rf

Of course, that doesn't work if you have anything with a space or any other wierd char

find . -print0 |xargs -n 1 --null grep CVS

Is an even worse mistake. (greps for CVS in the files themselves of course.)

<OT>
Of course I could try to not have tar extract files with CVS in the name, but that I never remember the right way to do that either.

address@hidden:/tmp/makediff# tar xvfz --exclude=CVS mycode.Aug9.tgz
tar: --exclude=CVS: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: mycode.Aug9.tgz: Not found in archive
tar: Error exit delayed from previous errors
</OT>

An EXAMPLE section in each the find and xargs page with some really cool stuff would be good I think. Especially for the ones of us with short memories.

Best wishes,
Jeff

Ah, I finally figured out something closer to what I want:

find . -printf "\"%p\"\n" |grep CVS |xargs -n 1 rm -f

find . -d -printf "\"%p\"\n" |rmdir

Something to just remove the CVS files. Sure it leaves the dirs, but I'm just doing 'diff -uNr olddir newdir' so it works

Or for dumping empty dirs:
find . -type d -printf "\"%p\"\n" |xargs -n 1 rmdir

Sure these might not be the most efficient, but they give clues to new users about how to use the tools together. Other man pages include examples like this (not the most efficient way but a good teaching method.) so perhaps you will find these worthy or make some better ones up.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]