LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell script: how to check read only file mode. (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-how-to-check-read-only-file-mode-596311/)

knockout_artist 11-01-2007 08:09 AM

Shell script: how to check read only file mode.
 
Good Day,

How do check if the file is read only?

I know if we need to check executable we do

Code:

if [-e filename]
.

Same way can we check if the file is read only.

Thanks.

pixellany 11-01-2007 08:17 AM

Look at "man test" ("[" is a synonym for "test")

-e is not for executable--it checks to see if the file exists

knockout_artist 11-01-2007 08:28 AM

Thank you.

I did check man test.

its -w.

Deus Absconditus 10-25-2015 02:14 AM

the existential -e test but what of -f ?
 
Quote:

Originally Posted by pixellany (Post 2944443)
Look at "man test" ("[" is a synonym for "test")

-e is not for executable--it checks to see if the file exists

Doesn't -f purport to check if a file is a file, oh, i just answered my own question:
-e checks to see if ANY file (directory or otherwise) exists answering to the name in the <filename>; whereas:
-f checks to see if the file in question is in fact a normal file

Would that be right?

chrism01 10-25-2015 07:00 PM

Bookmark this http://tldp.org/LDP/abs/html/fto.html - in fact read the whole doc :)

Deus Absconditus 10-25-2015 11:56 PM

Quote:

Originally Posted by chrism01 (Post 5440150)
Bookmark this http://tldp.org/LDP/abs/html/fto.html - in fact read the whole doc :)

Cheers.


All times are GMT -5. The time now is 11:10 PM.