[Sussex] Excluding hidden files and folders with find command [WAS: Sussex Digest, Vol 387, Issue 1]
Fay Zee
sussex at eglug.org.uk
Tue Sep 20 22:52:02 UTC 2011
On 20 September 2011 18:58, David Binderman wrote:
> $ find /home/fay -type f -name '*~' -print | grep -v 'whatever
pattern you
> want' | xargs rm
>
> sounds close to what you want. Even closer might be
>
> $ find /home/fay -type f -name '*~' -print | fgrep -v '/home/fay/.'
| xargs
> rm
>
> Suggest test it out first, though.
> The method I've given, using xargs, can have anything like grep,
fgrep,
> egrep, sed, perl or
> awk after the find, to restrict the list of filenames. Powerful, I
find.
> I first met Unix 30 years ago - a lot of this regexp technology is
even
> older.
Thanks for the tip, David. I like the -type option, which narrows down
the search, but I can't get to grips with the xargs today. I looked
carefully through the Wikipedia article and also a step-by-step
tutorial, but I will need more time.
However, re. fgrep, I found this
fgrep (grep -F in linux) is fixed or fast grep and behaves as grep but
does not recognise any regular expression metacharacters as being
special.
That could be worth looking into when i have the dots and slashes in
the path.
We haven't seen you at a moot recently ... do look out for the
upcoming talks.
Best Regards,
Fay
East Grinstead Linux User Group
www.eglug.org.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/sussex/attachments/20110920/53211a47/attachment-0001.htm>
More information about the Sussex
mailing list