| View previous topic :: View next topic |
| Author |
Message |
Toallpointswest
Joined: Tue Oct 17, 2006 5:02 pm Posts: 3 Location: America
|
Posted: Tue Mar 27, 2007 1:06 am Post subject: Fdupes vs. whitespaces problem! |
|
|
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 |
|
 |
Kev1729
Joined: Sun Mar 25, 2007 9:25 pm Posts: 25
|
Posted: Tue Mar 27, 2007 1:57 am Post subject: RE: Fdupes vs. whitespaces problem! |
|
|
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 |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 7993 Location: Warrington, UK
|
Posted: Tue Mar 27, 2007 9:27 am Post subject: RE: Fdupes vs. whitespaces problem! |
|
|
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. _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
Toallpointswest
Joined: Tue Oct 17, 2006 5:02 pm Posts: 3 Location: America
|
Posted: Tue Mar 27, 2007 4:47 pm Post subject: Re: RE: Fdupes vs. whitespaces problem! |
|
|
| 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 |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 7993 Location: Warrington, UK
|
Posted: Tue Mar 27, 2007 4:53 pm Post subject: RE: Re: RE: Fdupes vs. whitespaces problem! |
|
|
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. _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
Toallpointswest
Joined: Tue Oct 17, 2006 5:02 pm Posts: 3 Location: America
|
Posted: Tue Mar 27, 2007 10:33 pm Post subject: RE: Re: RE: Fdupes vs. whitespaces problem! |
|
|
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 previous topic :: View next topic |
|