LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2014, 11:46 PM   #1
farzanazhar
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Rep: Reputation: Disabled
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
 
Old 01-30-2014, 12:10 AM   #2
casualfred
Member
 
Registered: Aug 2012
Location: Kentucky, USA
Distribution: Slackware
Posts: 97

Rep: Reputation: 27
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!
 
2 members found this post helpful.
Old 01-30-2014, 12:15 AM   #3
farzanazhar
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
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
 
Old 01-30-2014, 08:46 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
No-one will do your work instead of you, but perhaps an example might help:

Code:
find . -type f -a ! -writable -exec ls -l {} \;
 
1 members found this post helpful.
Old 01-30-2014, 09:06 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by farzanazhar View Post
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.
 
1 members found this post helpful.
Old 01-30-2014, 11:32 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
man find
says:
Code:
-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.

Let us know.
 
Old 01-30-2014, 03:10 PM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Broken record, playing once again ...

As other's have said, please put forth an effort to try something.

Not an intro to bash scripting, but a lot of suggestions about being organized and fundamental when scripting; as well as some debug suggestions.

Bash Scripting for Dummies and Geniuses
 
Old 01-30-2014, 11:43 PM   #8
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Rep: Reputation: 29
Are any of them executable files? Who do you want to be able to write to them?
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] move files or a directory to another directory using shell script user1111 Linux - Newbie 6 11-15-2013 08:13 AM
Shell script to read all files from a directory and print the documents for_u_day@yahoo.com Linux - Newbie 1 02-16-2012 01:28 PM
help me list only linked files in my linux box using a shell script Hossana Linux - Newbie 4 09-06-2011 02:32 AM
Script to list files in a given directory Azzath Programming 8 04-03-2008 07:02 AM
Read list of files as arguments in a script garr0n Programming 10 10-25-2007 10:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration