Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fdupes vs. whitespaces problem!

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Linux Format forums Forum Index -> LXF Blog Comments
View previous topic :: View next topic  
Author Message
Toallpointswest



Joined: Tue Oct 17, 2006 5:02 pm
Posts: 3
Location: America

PostPosted: Tue Mar 27, 2007 1:06 am    Post subject: Fdupes vs. whitespaces problem! Reply with quote

I've been trying the fdupes command from this months issue to find and delete duplicate files
Quote:
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:
Quote:
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!
Back to top
View user's profile Send private message
Kev1729



Joined: Sun Mar 25, 2007 9:25 pm
Posts: 25

PostPosted: Tue Mar 27, 2007 1:57 am    Post subject: RE: Fdupes vs. whitespaces problem! Reply with quote

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.
_________________
http://kevscomputer.selfip.org
Back to top
View user's profile Send private message Visit poster's website
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8365
Location: Warrington, UK

PostPosted: Tue Mar 27, 2007 9:27 am    Post subject: RE: Fdupes vs. whitespaces problem! Reply with quote

xargs doesn't handle filenames with spaces at all well. If you replace "| xargs rm" with
Code:
| 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)
Back to top
View user's profile Send private message
Toallpointswest



Joined: Tue Oct 17, 2006 5:02 pm
Posts: 3
Location: America

PostPosted: Tue Mar 27, 2007 4:47 pm    Post subject: Re: RE: Fdupes vs. whitespaces problem! Reply with quote

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


That did something, but now I get:

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


So it looks like it didn't pass the variable correctly
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8365
Location: Warrington, UK

PostPosted: Tue Mar 27, 2007 4:53 pm    Post subject: RE: Re: RE: Fdupes vs. whitespaces problem! Reply with quote

More likely that the variable contained something rm didn't like. It should have deleted everything up to the dodgy item, so try
Code:
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)
Back to top
View user's profile Send private message
Toallpointswest



Joined: Tue Oct 17, 2006 5:02 pm
Posts: 3
Location: America

PostPosted: Tue Mar 27, 2007 10:33 pm    Post subject: RE: Re: RE: Fdupes vs. whitespaces problem! Reply with quote

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.
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Linux Format forums Forum Index -> LXF Blog Comments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast