Linux: locate, filenames with apostrophe, and xargs

I'm working on building my new Fedora 13 laptop (Studio XPS 16 which is awesomely fast)
Anyway, in trying to de-duplicate a lot of files that I have spread across my old Fedora server and Mac Mini.
The worst offenders are my MP3 files that I've downloaded and in many cases imported into iTunes.  So I've been using locate and xargs to compare file sizes and make sure I have 1 good copy of every MP3.
Many songs have special punctuation like "'" in them which causes xargs problems.  But since I'm using locate and not find, I had to replace newlines with NULL (\0).
Here's a quick little hack for that.

locate -i "ring of fire" | perl -e 'while (<STDIN>) { chomp $_; print $_ . "\0" }' | xargs -0 -I {} ls -l {}

Comments

Popular posts from this blog

Xubuntu Home Server on Dell XPS 13 9370

Cygwin + syslog-ng

Installing Fedora 21 on a (late 2014) Mac Mini