-1

I have (by mistake) created several files starting with a dash in my home directory. I can not select them nor delete them.

# ls -lht
-rw-r--r--  1 root  root  325 Mar 22 16:33 -s-vmstat-overall
-rw-r--r--  1 root  root 2.7K Mar 22 16:33 -s-vmstat
-rw-r--r--  1 root  root 8.4K Mar 22 16:32 -s-df
-rw-r--r--  1 root  root  29K Mar 22 16:32 -s-diskstats
-rw-r--r--  1 root  root  12K Mar 22 16:32 -s-interrupts
-rw-r--r--  1 root  root 9.7K Mar 22 16:32 -s-meminfo
-rw-r--r--  1 root  root 155K Mar 22 16:32 -s-mysqladmin
-rw-r--r--  1 root  root 203K Mar 22 16:32 -s-netstat
-rw-r--r--  1 root  root  37K Mar 22 16:32 -s-netstat_s
-rw-r--r--  1 root  root  766 Mar 22 16:32 -s-output
-rw-r--r--  1 root  root  11K Mar 22 16:32 -s-procstat
-rw-r--r--  1 root  root  13K Mar 22 16:32 -s-procvmstat
-rw-r--r--  1 root  root 175K Mar 22 16:32 -s-slabinfo

How to remove all such files starting with -s-

shantanuo
  • 3,579
  • 8
  • 49
  • 66

2 Answers2

4

Unix commands use the - prefix to indicate options; use the -- "option" to stop option processing, or prefix filenames with ./ (or an absolute path).

rm -- -s-df
rm ./-s-vmstat

You might want to look up an introduction to the Unix/Linux command line environment, as this is a FAQ.

geekosaur
  • 7,175
  • 1
  • 20
  • 19
3
rm ./-s-*

Isn't this a FAQ yet? Should it perhaps be one, if not?

MadHatter
  • 79,770
  • 20
  • 184
  • 232