To find files whos filenames have a certain length, you can use various combinations of the ls
, egrep
and find
commands.
E.g. find files that have 9 characters followed by .txt:
me@pc ~/tmp $ ls ?????????.txt
analytics.txt capilinks.txt particles.txt tmp123123.txt tmp123333.txt
me@pc ~/tmp $ ls | egrep '^.{9}.txt'
analytics.txt
capilinks.txt
particles.txt
tmp123123.txt
tmp123333.txt
You can also use find
, but this will search by full path not just filename:
me@pc ~tmp $ find . -regextype posix-egrep -regex '^./.{9}.txt'
./vlad/test.txt
./particles.txt
./tmp123123.txt
./capilinks.txt
./analytics.txt
./tmp123333.txt
Reference: How can I search for a file with fixed name length using ls?