You are not logged in.

#1 2010-02-02 23:21:03

Skoll
Member
Registered: 2009-09-23
Posts: 36

[SOLVED] xargs - escape special characters

I'm using duff to find duplicate files and pipe the output to xargs in order to delete them but some of those files have names with special characters, i.e. blanks, apostrophes. I'm still learning bash and sed so I can't escape all of those characters, could someone help me?

The command I'm using is, though it doesn't escape characters:
duff -e -r folder | xargs rm

Last edited by Skoll (2010-02-03 17:10:11)

Offline

#2 2010-02-02 23:52:59

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: [SOLVED] xargs - escape special characters

I don't use duff, what are your options for how the output is delimited? If it's delimited by newlines, you could use:

your duff command | xargs -d$'\n' rm

Offline

#3 2010-02-03 17:09:28

Skoll
Member
Registered: 2009-09-23
Posts: 36

Re: [SOLVED] xargs - escape special characters

The output is delimited by newlines so it worked. I should have checked the man of xargs. Thanks for your help and patience. smile

Could you suggest better programs to find duplicates?

Offline

#4 2010-02-03 17:51:19

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: [SOLVED] xargs - escape special characters

Sorry, I just use diff or vimdiff, and that's only feasible when you have an idea of which files are likely to be duplicates of each other. (Or a recipe for generating two lists, the nth element of each is likely to be a duplicate of the nth element of the other, stuff like that...) I get the impression from this thread that duff tries to find duplicates more aggressively. If there are other programs that do that as well, I don't know what they are.

Offline

Board footer

Powered by FluxBB