Solved

Automatically changing the permissions of only certain files in subdirectories

Posted on 2004-03-28
6
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10698288
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
ID: 10698292
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
ID: 10704517
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10705071
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
ID: 10705157
True, but no chance for "argument list too long" error :)
0
 
LVL 44

Expert Comment

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

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

730 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