The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Automating Autosys LilyClaro UNIX for Advanced & Expert Users 0 03-23-2007 10:15 AM
Automating telnet and ftp sendhilmani123 Shell Programming and Scripting 2 04-25-2006 02:37 AM
Automating sendmail JimJim Shell Programming and Scripting 3 11-30-2004 03:31 AM
automating password ? Liamo Shell Programming and Scripting 3 05-24-2004 03:01 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-04-2008
Registered User
 

Join Date: Jan 2008
Posts: 6
Unprintable filenames and automating a chmod

I have a fair amount of files in multiple directoroes that need to have an attribute modified, so a script is in order. Initially it seemed like creating a script with a find and then pipe it to xargs chmod would do the trick. Enter into the equation non-printable filenames... ugh... Has anyone in the forum dealt with this with any luck?

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 02-04-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
You can deal with weird characters by assigning the filename to a variable, when you reference the variable, surround it in quotes. This works almost all of the time.
Code:
find ./someplace -name 'somefiles*' |\
while read filename
do
    chmod +x "$file"
done
This may also work on your system:
Code:
find ./someplace -name 'somefiles*' -exec chmod +x "{}"
Reply With Quote
  #3  
Old 02-06-2008
Registered User
 

Join Date: Jan 2008
Posts: 6
Thanks for the response, however, I still have the issue to deal with and perhaps I didn't explain the problem enough...

The script I originally came up with is:

find . \( -perm -0002 -a -type f \) | xargs chmod o-w

The 95% rule works here and the 5% fall through is what I'm looking to cover. The files with unprintable characters in the names passed to the chmod results in an unable to access message. I'm guessing that the last chacter in the filename value may be a null character? I'm guessing this simply because when I chmod against the individual file appended with a '*" I'm successful...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0