Reference number: CH000651
How do I rm or mv a file that begins with a dash?
Question:How do I rm or mv a file that begins with a dash?
Answer:Files that begin with a hyphen
(dash) can be tricky to remove because Linux or Unix will
interpret the character after the dash as an option. For example, if
the user attempts to type the below command they would receive the
error also shown below.
mv -myfile.txt myfile.txt
mv: invalid option -- m
Try `mv --help' for more information.
In the above example the operating system is interpreting the -m
as a switch. For this command to work you must type the below
command.
mv ./-myfile.txt myfile.txt
Typing this command will rename the file in the current directory
and will cause Linux or Unix to not notice the dash.
|