2

I tried to copy all the files under a directory by simply issuing "cp * /dst_dir", but Shell showed:

~/git$ cp * ~/dst_dir
cp: invalid option -- 'o'

Then issued "ls -1" to list all the files, found the culprit is some files with prefix '-' like below.

   -count
   -sdds
   ...

Don't know how these files were generated, moreover I still can't find a way to remove or move these "-xxx" files.

   ~/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.

BTW, my shell is TCSH on RHEL 6.3, "tcsh --version" shows:

    ~/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

Anyone has any clue on this problem. Your help would be much appreciated.

Update

Thanks all. I checked manual just now, found the official answer below:

   To remove a file whose name starts with a '-', for example '-foo',  
   use one of these commands:

      rm -- -foo

      rm ./-foo
thinkhy
  • 923
  • 13
  • 25
  • 1
    By the way, most commands view the strings after the `--` as command arguments, not options – zhujs Jul 19 '14 at 04:57
  • possible duplicate of [how to remove a file whose name starts with '-'](http://stackoverflow.com/questions/22048216/how-to-remove-a-file-whose-name-starts-with) – ldav1s Jul 19 '14 at 05:05

2 Answers2

5

Try the command rm -- -count, or rm ./-count, check the man page of rm. Similarly, cp -- * ~/dst_dir to copy the files

zhujs
  • 543
  • 2
  • 12
2

As always, specify a full path.

rm ./*
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358