Re removing hyphens from filenames

Peter Corlett abuse at
Thu Jul 12 12:34:55 BST 2007

On Thu, Jul 12, 2007 at 12:15:59PM +0100, Jamie Nicholson wrote:
>> Oh that's *easy*! And there's only /one/ way to do it ...
> You reckon? I've found it defers from UNIX / shell, it's abit of a pain
> though. Try single quotes to start off i.e. rm 'file-name'. You might then
> try escaping the hypen though I don't think that work rm file\-name, or
> then if all else fails try a rm -i *.

"Removing hyphens from filenames" is a different problem from "removing
files whose name starts with a hyphen".

find . | sort -r | perl -ne 'chomp; $a=$_; s/-//g; rename $a, $_ or die "Rename $a to $_ failed: $!"'

would probably do it. There's probably some clever Unix filter I've
forgotten that would have saved me breaking out the Perl.

> That could possibly get it :) But like a previous poster said why the heck
> would people be asking this here anyway.

I've got a better question. Why on earth did you append a list archive to
your post?

More information about the mailing list