相关疑难解决方法(0)

如何删除以双连字符开头的文件?

我的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)

但没有任何作用.

如何在终端上删除这些文件?

unix bash filenames

66
推荐指数
4
解决办法
2万
查看次数

rm无法删除以 - 开头的文件

我有一个创建文件的脚本,有时他们最初有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)

linux bash shell rm

5
推荐指数
3
解决办法
4921
查看次数

如何复制前缀为' - '的文件?

我试图通过简单地发出"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)

unix linux shell file

2
推荐指数
1
解决办法
946
查看次数

标签 统计

bash ×2

linux ×2

shell ×2

unix ×2

file ×1

filenames ×1

rm ×1