Fedora Linux Support Community & Resources Center
  #1  
Old 11th August 2009, 08:07 PM
shabakeh Offline
Registered User
 
Join Date: Jan 2008
Posts: 162
linuxfedorafirefox
Running chmod on files with a particular extension

hi everyone

I have a directory with a lot of subdirectories and files. How can I write a bash script that add x permissions to .sh files only. or how can I change owner of files that has .sh extension? thanks in advance
Reply With Quote
  #2  
Old 11th August 2009, 08:53 PM
scottro's Avatar
scottro Offline
Retired Community Manager -- Banned from Texas by popular demand.
 
Join Date: Sep 2007
Location: NYC
Posts: 8,142
linuxkonqueror
I've moved the thread to programming, which seems more suited. I've also given it a more specific title. (Busy people tend to just skip threads with vague titles)

I suspect you want to use find with either -exec or xargs to do this. I would try starting by googling for

find tutorial

http://www.softpanorama.org/Tools/Fi...tutorial.shtml

Ah, I think that is the one that I had in mind.
__________________
--
http://home.roadrunner.com/~computertaijutsu

Do NOT PM forum members with requests for technical support. Ask your questions on the forum.


"I don't know why there is the constant push to break any semblance of compatibility" --anon
Reply With Quote
  #3  
Old 12th August 2009, 02:33 AM
ghostdog74 Offline
Registered User
 
Join Date: Sep 2006
Posts: 52
linuxfedorafirefox
Code:
find /path -type f -name "*.sh" -exec chmod u+x "{}" +;
or
Code:
find /path -type d | while read DIR
do
 chmod .... *.sh
done
Reply With Quote
  #4  
Old 12th August 2009, 10:28 AM
BlueC Offline
Registered User
 
Join Date: Aug 2007
Location: Liverpool, UK
Posts: 733
macosfirefox
ghostdog, question:

what's the difference between using that "+" at the end and using a "\" ?

you wrote:

Code:
find /path -type f -name "*.sh" -exec chmod u+x "{}" +;
but I would always do:

Code:
find /path -type f -name "*.sh" -exec chmod u+x "{}" \;
just wondering like...?

Chris
Reply With Quote
  #5  
Old 12th August 2009, 11:36 AM
kramulous Offline
Registered User
 
Join Date: Dec 2007
Location: Brisbane, Australia
Posts: 65
linuxfedorafirefox
Wouldn't mind an answer to the difference myself, I'd use

Code:
find . -type f -name "*.sh" -exec chmod u+x {} \;
Reply With Quote
  #6  
Old 12th August 2009, 12:15 PM
ibbo's Avatar
ibbo Offline
Registered User
 
Join Date: Jun 2005
Location: Leeds
Posts: 1,264
linuxdebianmozilla
cd Folder

# Make exe
chmod -R 0755 *.sh

# change user
chown -R <user>:<group> *.sh

No need for find as we know where they are located. We simply need -R to recursively poll the sub directories for *.sh files and then act upon them.

Ibbo
__________________
A Hangover Lasts A Day, But Our Drunken Memories Last A Lifetime
--
Linux user #349545
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCfdjyzXscddzQvlhBedAcD7qfKmHo==zx0H
Reply With Quote
  #7  
Old 12th August 2009, 02:26 PM
ghostdog74 Offline
Registered User
 
Join Date: Sep 2006
Posts: 52
linuxfedorafirefox
Quote:
Originally Posted by BlueC View Post
ghostdog, question:

what's the difference between using that "+" at the end and using a "\" ?

you wrote:

Code:
find /path -type f -name "*.sh" -exec chmod u+x "{}" +;
but I would always do:

Code:
find /path -type f -name "*.sh" -exec chmod u+x "{}" \;
just wondering like...?

Chris
+; at the end is supported by recent version of find. it has the same effects as using find with xargs. check the man page for more details
Reply With Quote
Reply

Tags
chmod, extension, files, running

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
unzip files extension r00 r01 etc mathematics314 Using Fedora 6 24th November 2006 02:47 PM
chmod for many dirs and files? alxle Using Fedora 6 15th November 2006 04:05 PM
Problem whit vsftpd cant chmod files adapter Using Fedora 7 14th September 2006 02:41 AM
Files extension sh finsh Using Fedora 3 11th May 2006 08:31 PM
chmod ing files from desktop kathymacau Using Fedora 2 24th October 2005 03:03 AM


Current GMT-time: 06:23 (Monday, 20-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat