|
Home > Archive > Unix Shell > January 2006 > yet another find/xargs .file question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
yet another find/xargs .file question
|
|
| unfrostedpoptart 2006-01-23, 2:55 am |
| I thought I had it, but I lost it!
I'm trying to remove all files in a hierarchy that start with . (dot).
These are a ton of hidden files that my Mac added to my music folder
that are confusing Windows when it looks at the same directories.
I found this command listed them all:
find . -name \.\* -type f
However, if I try and use xargs (trying a list before I try rm) like
this:
find . -name \.\* -type f | xargs ls -l
it freaks out because of spaces in filenames and directory names. How
do I get past this?
Thanks,
David
| |
| Chris F.A. Johnson 2006-01-23, 2:55 am |
| On 2006-01-23, unfrostedpoptart wrote:
> I thought I had it, but I lost it!
>
>
> I'm trying to remove all files in a hierarchy that start with . (dot).
> These are a ton of hidden files that my Mac added to my music folder
> that are confusing Windows when it looks at the same directories.
The obvious solution is: Don't use Windows.
> I found this command listed them all:
> find . -name \.\* -type f
>
>
> However, if I try and use xargs (trying a list before I try rm) like
> this:
>
> find . -name \.\* -type f | xargs ls -l
>
> it freaks out because of spaces in filenames and directory names. How
> do I get past this?
The universal method is:
find . -name \.\* -type f -exec rm {} \:
Some versions of find support -print0 (and xargs the corresponding
-0); it is supported on FreeBSD, so I expect Mac OSX has it, too:
find . -name \.\* -type f -print0 | xargs -0 rm
POSIX versions of find support this, which builds a command line
in the same way as xargs:
find . -name \.\* -type f -exec rm {} +
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
| |
| unfrostedpoptart 2006-01-23, 2:55 am |
|
Chris F.A. Johnson wrote:
> On 2006-01-23, unfrostedpoptart wrote:
>
>
>
> The universal method is:
>
> find . -name \.\* -type f -exec rm {} \:
Thanks Chris, this worked, although it wanted a semi-colon, not a
colon, at the end of the command.
David
| |
| Chris F.A. Johnson 2006-01-23, 2:55 am |
| On 2006-01-23, unfrostedpoptart wrote:
>
> Chris F.A. Johnson wrote:
>
> Thanks Chris, this worked, although it wanted a semi-colon, not a
> colon, at the end of the command.
My typo; it should have been a semi-colon.
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
|
|
|
|
|