I'm trying to rename a file with a hyphen at the beginning of its name and both this:
mv -example-file-name example-file-name
and this:
mv '-example-file-name' example-file-name
result in:
mv: invalid option -- 'e'
Answer
Most GNU/Linux commands allow a --
option to indicate end of options so that subsequent -
prefixed words are not treated as options.
mv -- -example-file-name example-file-name
A small test
$ touch -- -example
$ ls -l -- *ample
-rw-r--r-- 1 rgb rgb 0 Nov 25 09:57 -example
$ mv -- -example example
$
No comments:
Post a Comment