我的Unix机器上有一些文件开头
--
Run Code Online (Sandbox Code Playgroud)
例如 --testings.html
如果我尝试删除它,我会收到以下错误:
cb0$ rm --testings.html
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
Run Code Online (Sandbox Code Playgroud)
我试过了
rm "--testings.html" || rm '--testings.html'
Run Code Online (Sandbox Code Playgroud)
但没有任何作用.
如何在终端上删除这些文件?
我有一个创建文件的脚本,有时他们最初有2个破折号,有没有办法删除它们mv不起作用
这是我得到的错误
$ ls
--1355509766.jpg
$ rm --1355509766.jpg
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
$ rm "--1355509766.jpg"
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
Run Code Online (Sandbox Code Playgroud) 我试图通过简单地发出"cp*/dst_dir"来复制目录下的所有文件,但Shell显示:
~/git$ cp * ~/dst_dir
cp: invalid option -- 'o'
Run Code Online (Sandbox Code Playgroud)
然后发出"ls -1"列出所有文件,发现罪魁祸首是一些带有前缀' - '的文件,如下所示.
-count
-sdds
...
Run Code Online (Sandbox Code Playgroud)
不知道这些文件是如何生成的,而且我还是找不到删除或移动这些"-xxx"文件的方法.
~/git$ rm "-count"
rm: invalid option -- 'c'
Try `rm ./-count' to remove the file `-count'.
Try `rm --help' for more information.
~/git]$ mv \-count /tmp
mv: invalid option -- 'c'
Try `mv --help' for more information.
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我的shell是RHEL 6.3上的TCSH,"tcsh --version"显示:
~/git]$ tcsh --version
tcsh --version
tcsh 6.17.00 (Astron) 2009-07-10 (x86_64-unknown-linux) options wide,nls,dl,al,kan,rh,color,filec
Run Code Online (Sandbox Code Playgroud)
任何人都有任何关于这个问题的线索.非常感谢您的帮助.
谢谢大家.我刚检查手册,发现以下官方答案:
To remove a file whose name starts …Run Code Online (Sandbox Code Playgroud)