Linux shell command help needed - file path length

Man of Honour
Joined
18 Oct 2002
Posts
13,262
Location
Northallerton/Harrogate
Hi,

I need to list the contents of a folder structure, including the length of the total path for each file in # of characters.

Is this possible?

I'm not too hot with linux.
find -name "*.wr" -print doesn't really do what i need.

It's just the length of the whole folder structure for each file I need.
Or even better, just list those files which are above a certain length, e.g. 60 chars..

Any ideas?
 
Code:
for i in `find -name "*.wr"`; do echo -en "$i\t"; echo $i | wc -c; done
will show the filenames and filename lengths.

Code:
for i in `find -name "*.wr"`; do if [ `echo $i | wc -c` -ge 60 ]; then echo $i; fi; done
will display filenames of 60+ characters.
 
THIS:

Code:
#!/bin/bash
for f in $(ls -b /home/user/ ); do
 length=`echo $f | wc -c`

if [ $length -gt 60 ]; then
        echo $f ; echo $f | wc -c
fi
done
but I don't know why it doesn't work.....

edit - ahh must use -gt and not > now it works. edit as required :)
 
Last edited:
Back
Top Bottom