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
^[0-9]
to explicitly match filenames beginning with a digit (as per the question). – Anthony Geoghegan Jan 16 '17 at 09:43find
adds the relative path to the output, so in this case a./
, so that wouldn't work. – ganzpopp Jan 16 '17 at 09:45-name '*[0-9]'
) which is not what is being asked for here. That would also look for those files in subdirectories which is not asked for either. – Stéphane Chazelas Jan 16 '17 at 09:52^\./[0-9].*
would work. I think using a regex makes the command more complicated than it needs to be. Using-name
with a shell globbing pattern should be sufficient, e.g.,find . -name '[0-9]*'
. The advantage of usingfind
over slm’s excellent answer is that it could be used recursively (though that isn’t relevant to this specific question). – Anthony Geoghegan Jan 16 '17 at 10:03