Hi,

I need to search a large Directory Path and count all the characters(Even filenames with space and special chars, etc.) in it.
Example:

/data/general\Customer_Order_Files\Pump_Files\Pump_Open_Files\1217697 METSO MINERALS HITACHI AMERON DUCK CREEK\1217697 MOTOR INFO METSO MIN HITACHI AMER DUCK CREEK 10-3-06\1217697 Motor Quote SIEMENS METSO MIN HIT AMER DUCK CREEK 10-16-06 .pdf

We are trying to search all Directory paths that users have created and limit them to 240 chars or 10 Directory levels and 24 chars per Directory or Filename for a full character count of 240.

Why you ask? <smile>
We have encountered issues trying to copy the above file path to a Windows 2003 server from Linux via Samba share.

Any help is greatly appreciated!

Thanks.

SP

find . - type f | awk -F/ '$NF > 10 && length($0) > 240 { print "Bad\n" }'

Hi Salem,

A great example but how do I list the directory's instead of printing "bad"?
Also, can I print out results with number of characters like:

/data/general/... : 230 chars

I appreciate your help!
TIA.

SP

find . - type f | awk -F/ '$NF > 10 && length($0) > 240 { print "Bad\n" }'

Hey There,

You can print out the name of the found file by printing out $0 and the number of characters by printing NF -- You'll be doing both within the awk statement and it's important to print NF for the number. If you print $NF you'll get the value of the last field.

Hope that helps :)

, Mike

As with many of my posts, it's not an answer which you can simply copy/paste into your problem and expect it to work.

It's to show you what's possible in the hope that you'll then be able to apply that new insight to your own problem in your own way, and in the process learn something.

As with many of my posts, it's not an answer which you can simply copy/paste into your problem and expect it to work.

It's to show you what's possible in the hope that you'll then be able to apply that new insight to your own problem in your own way, and in the process learn something.

Hi Salem,

Yes, I understand, I 'll give more details from now on.
Thanks for your info. I did figure it out on my own after posting in a panic for time. <smile>


SP

Thanks for the answer Eggi and the answer.
Sorry to be pest...

SP

Glad to help :)

Apologies if I overstepped any forum boundaries. As luck would have it, I didn't provide a cut-and-paste answer either :)

, Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.