*-* will match any name in the current directory that contains a dash (literally "a name that contains at least one
-, possibly prefixed and/or suffixed by some other string"). This means that you should be able to do
rm -- *-*
to delete all files with names containing a
- character in the current directory.
zsh shell, using
*-*(.) as the pattern would restrict the match to only regular files (not directories, although
rm would not be able to delete directories anyway).
If these are too many files for
rm to handle in one go, use
find like so:
find . -maxdepth 1 -type f -name '*-*' -delete
-maxdepth 1 to restrict the search to only the current directory, and I added
-type f to only delete regular files.
You could also use a (somewhat slow) loop:
for name in ./*-*; do
Some people prefer "one-liners", and this loop could be written as
for name in ./*-*; do rm "$name"; done
... although typing it as a multi-line command would definitely be possible in most modern shells.