Rm -f files starting with a digit

rm

I've accidentally redirected the output of a CSV file to my directory. How can I rm only the files that start with a number, and leave the files that start with a letter intact?

mymachine$ ls
71.24         README.md        30            4.29
8             filter.sh        42.81         5.58         
8.36          purchases.csv    1,208.8       100          
16.7          2.56             21.78         269.96        

Best Answer

Something like this should do it:

$ rm [0-9]*

Remember you can always use echo with any globbing arguments prior to letting rm run with them.

$ echo [0-9]*
100 1,208.8 16.7 21.78 2.56 269.96 30 42.81 4.29 5.58 71.24 8 8.36

After running the rm command above:

$ ls
filter.sh  purchases.csv  README.md
Related Question