If having problem renaming a file that starts with a dash:
Since the file name begins with a '-' it looks like an option to the
command. You need to force it to not look like an option. Put a ./
in the front of it. Or give it the full file name path. Or tell the
command you are through with options by using the double dash to end
all option processing. This is common to most traditional UNIX
commands.
cp ./* /some/folder
cp -- * /some/folder
And the same for other utilities too.
mv ./-stuff differentstuff
mv -- -stuff differentstuff
8 comments:
Thanks, this was frustrating me
Thanks for this (should have been obvious) solution.
Thanks. That really helped me a lot.
Thank you!
thank you very much.
Very useful
To batch rename files starting with hyphen:
rename 's/-//' ./*
Thanks for posting this, and Google helping me find it. :)
Wow, ten years of linux administration and this stumped me for a bit! I need more caffeine.
Thanks for the post, mate!
Post a Comment