Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove files with filenames all in uppercase in linux?

Tags:

linux

bash

Say I have a directory containing the following files:

ls

ABC BCD CDE DEF abc bcd cde def Abc

How to remove all the files with filenames all in uppercase? (remove ABC BCD CDE DEF in this case)


1 Answers

Using GNU find:

find . -maxdepth 1 ! -name '*[![:upper:]]*' -delete

Note that this does not descend into subdirectories and does not delete non-empty directories whose filenames are all in uppercase.

like image 163
oguz ismail Avatar answered Oct 31 '25 13:10

oguz ismail