How do I search for all files of a certain length in a directory, in UNIX? For example, how do I search for all files whose names are of length 5 in the directory /blah?
I've looked all over and I can't find it at all.
Anything wrong with
ls /blah/?????
As in
$ ls blah/*
blah/apple blah/bananas blah/pears blah/pie
$ ls blah/?????
blah/apple blah/pears
find /blah -maxdepth 1 -iname '?????' -xtype f
iname
(case insensitive) if all you are matching is wildcards... Otherwise, exactly what i was looking for.
You can use this:
ls | awk '{if (length($1)==10) print $1}'