Solved

Automatically changing the permissions of only certain files in subdirectories

Posted on 2004-03-28
6
258 Views
Last Modified: 2010-04-20
Hello.

I need to change the permission of all files with the following extentions inside of a certain directory to 777:
.dat
.bak
.lock

There are over 200 files in 15 sub-directories.

I have ssh access. How can I change the permissions of all the files in all the subdirectories at once? Thanks!
0
Comment
Question by:perldog
  • 4
  • 2
6 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
Use the find command:

find /path/to/parent -name "*.dat" -print | xargs chmod 777
find /path/to/parent -name "*.bak" -print | xargs chmod 777
find /path/to/parent -name "*.lock" -print | xargs chmod 777
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 230 total points
Comment Utility
You can also combine the three extensions into one command:
find /path/to/parent -name "*.dat" -print , -name "*.bak" -print , -name "*.lock" -print | xargs chmod 777

0
 
LVL 9

Assisted Solution

by:tkalchev
tkalchev earned 20 total points
Comment Utility
Or try this one (it is almost equivalent ) :

find /path/to/parent -name "*.dat" -exec chmod 777 {} \; , -name "*.bak" -exec chmod 777 {} \; , -name "*.lock" -exec chmod 777 {} \;
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
tkalchev,
your solution will be slower: You are forking the chmod command for every single file. The xargs mechanism collects a number of file names and then forks one chmod command for a number of files.
0
 
LVL 9

Expert Comment

by:tkalchev
Comment Utility
True, but no chance for "argument list too long" error :)
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
... and for 200 files it does not make a big difference :-)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now