Shell script to list all files in the specified directory which have only read permis
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Shell script to list all files in the specified directory which have only read permis
Hi,
How to write a SHELL Script to list all files in the specified directory which have only read permission and append write permission also to them.
Please respond to this and help me out
Basically, you will want to use the 'find' command and the 'chmod' command in your script. I would recommend reading their man pages for their exact usage. Good luck!
Actually I am a fresher to Unix. Can you please post the complete script so that i can understand and thank you for your reply.But please post the full script
Actually I am a fresher to Unix. Can you please post the complete script so that i can understand and thank you for your reply.But please post the full script
As said, we're not going to write your scripts for you, but we WILL help you. You were given a hint with the find command, but didn't show any effort of your own. There are THOUSANDS of VERY easily-found scripting tutorials...did you try to look ANY of them up? Do ANY work of your own??
If you don't actually do anything for yourself, you will NEVER learn anything, about ANY subject.
-perm mode
File's permission bits are exactly mode (octal or symbolic). Since an exact match is required, if you want
to use this form for symbolic modes, you may have to specify a rather complex mode string. For example -perm
g=w will only match files which have mode 0020 (that is, ones for which group write permission is the only
permission set). It is more likely that you will want to use the `/' or `-' forms, for example -perm -g=w,
which matches any file with group write permission. See the EXAMPLES section for some illustrative examples.
-perm -mode
All of the permission bits mode are set for the file. Symbolic modes are accepted in this form, and this is
usually the way in which would want to use them. You must specify `u', `g' or `o' if you use a symbolic
mode. See the EXAMPLES section for some illustrative examples.
-perm /mode
usually the way in which would want to use them. You must specify `u', `g' or `o' if you use a symbolic
mode. See the EXAMPLES section for some illustrative examples.
-perm /mode
Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must
specify `u', `g' or `o' if you use a symbolic mode. See the EXAMPLES section for some illustrative examples.
If no permission bits in mode are set, this test matches any file (the idea here is to be consistent with the
behaviour of -perm -000).
Using that info and the provided EXAMPLES here and in the man file, crafting a solution is left as an exercise for you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.