Fdupes vs. whitespaces problem!

Discuss LXF Team Blog entries here

Moderators: ChrisThornett, LXF moderators

Fdupes vs. whitespaces problem!

Postby Toallpointswest » Tue Mar 27, 2007 12:06 am

I've been trying the fdupes command from this months issue to find and delete duplicate files
fdupes --recurse --omitfirst <directory> |xargs rm

And every time it comes across a file or pathname with a whitespace in it I get the following error:
rm: cannot remove '<file or directory with whitespace>': No such file or directory


Any ideas how I can get this command to work properly? Thanks!
Toallpointswest
 
Posts: 3
Joined: Tue Oct 17, 2006 4:02 pm
Location: America

RE: Fdupes vs. whitespaces problem!

Postby Kev1729 » Tue Mar 27, 2007 12:57 am

If you use it with the --delete flag it works fine, else if you are using your own script (or indeed one that came with the mag, shows how much i read it) to delete the files you would need to escape the filenames first.
Kev1729
 
Posts: 25
Joined: Sun Mar 25, 2007 8:25 pm

RE: Fdupes vs. whitespaces problem!

Postby nelz » Tue Mar 27, 2007 8:27 am

xargs doesn't handle filenames with spaces at all well. If you replace "| xargs rm" with
Code: Select all
| while read f; do rm "$f"; done
your spaced put files should be deleted correctly.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8490
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Re: RE: Fdupes vs. whitespaces problem!

Postby Toallpointswest » Tue Mar 27, 2007 3:47 pm

nelz wrote:xargs doesn't handle filenames with spaces at all well. If you replace "| xargs rm" with
Code: Select all
| while read f; do rm "$f"; done
your spaced put files should be deleted correctly.


That did something, but now I get:

rm: cannot remove `':No such file or directory


So it looks like it didn't pass the variable correctly
Toallpointswest
 
Posts: 3
Joined: Tue Oct 17, 2006 4:02 pm
Location: America

RE: Re: RE: Fdupes vs. whitespaces problem!

Postby nelz » Tue Mar 27, 2007 3:53 pm

More likely that the variable contained something rm didn't like. It should have deleted everything up to the dodgy item, so try
Code: Select all
fdupes --recurse --omitfirst <directory> | head

to see what comes next.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8490
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

RE: Re: RE: Fdupes vs. whitespaces problem!

Postby Toallpointswest » Tue Mar 27, 2007 9:33 pm

Tried it on another directory, and I have the file list I expected, so I'll try it again.

EDIT: Okay tried it again and, it creates a listing of file names, with a blank line in between each line. I think that the error I'm seeing is rm trying to delete that blank line, as when I re-run fdupes on that directory it finds no dupes, so it is working.
Toallpointswest
 
Posts: 3
Joined: Tue Oct 17, 2006 4:02 pm
Location: America


Return to LXF Blog Comments

Who is online

Users browsing this forum: No registered users and 0 guests

cron