[lug] find command or similar
John E. Koontz
koontz at boulder.nist.gov
Tue May 13 11:20:02 MDT 2003
At 10:20 AM 5/13/2003 -0600, Stephen wrote:
>Will someone please explain how I can find all files on a system with a
>name containing more than 200 characters?
The strategy to use here is the classic Unix divide and conquer (read,
"divide and paste together with pipes").
To list all file names in a tree, something like
find . -printf '%f\n'
I had to look up -printf '%f\n' because I usually fall back on the default,
which lists full pathnames.
I don't know enough about find to make it select filenames based on
filename lengths, if it can do that, and I don't know a command that does
that directly, if there is one, but you can always fall back on awk (or
perl, or whatever).
With awk, you pipe the output of the foregoing through
awk "length()>200 {print}"
I'd test this with shorter lengths to make sure it's doing exactly what you
want.
I'll leave modifying the awk predicate length()>200 (short for
"length($0)>200") to select ranges of lengths as an exercise to the reader
...
I used the find and awk (or gawk) man pages to refresh my mind on the
details.
John E. Koontz
NIST 896.04 PCSG
303-497-5180
N39° 59' 42.1" W 105° 15' 49.7"
More information about the LUG
mailing list