•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 391,779 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,458 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 955 | Replies: 7
![]() |
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
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
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" }' If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
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
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" }'
•
•
Join Date: Oct 2007
Posts: 256
Reputation:
Rep Power: 1
Solved Threads: 26
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
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
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
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.
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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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
•
•
Join Date: Oct 2007
Posts: 256
Reputation:
Rep Power: 1
Solved Threads: 26
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

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

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
Similar Threads
- Open In New Window Php (PHP)
Other Threads in the Shell Scripting Forum
- Previous Thread: Script to move files from one location to another
- Next Thread: Simple awk help



Linear Mode