【发布时间】:2014-09-10 06:30:55
【问题描述】:
我试图通过简单地发出“cp * /dst_dir”来复制目录下的所有文件,但Shell显示:
~/git$ cp * ~/dst_dir
cp: invalid option -- 'o'
然后发出“ls -1”列出所有文件,发现罪魁祸首是一些带有前缀'-'的文件,如下所示。
-count
-sdds
...
不知道这些文件是如何生成的,而且我仍然找不到删除或移动这些“-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.
顺便说一句,我的外壳是 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
任何人都对这个问题有任何线索。非常感谢您的帮助。
更新
谢谢大家。刚才查了手册,官方给出的答案如下:
To remove a file whose name starts with a '-', for example '-foo',
use one of these commands:
rm -- -foo
rm ./-foo
【问题讨论】:
-
顺便说一句,大多数命令将
--之后的字符串视为命令参数,而不是选项