13th January
2009
I was restoring some files from backup today and ran into a few files that had leading slashes. Whenever I see those kind of things I rename the files since they are a pain to work with in the shell.
If you find yourself at a shell and need to work with files that have a leading dash just use the relative path and include the dashed filename in quotes.
mv ./"-somefile.txt" ./somefile.txt
Identica
Twitter
LinkedIn
Couldn’t you also do:
mv — -somefile.txt somefile.txt
Or, you can use a double dash to make mv, cp to stop interpreting options:
mv — -somefile.txt somefile.txt
Or simply use “–” to signal the end of options. As in:
mv — -somefile.txt somefile.txt
You could double dash.
Or backslash escape the offending character.
mv \-somefile.txt somefile.txt
Oh no you can’t. Ignore that