LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2007, 08:09 AM   #1
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Rep: Reputation: 33
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.
 
Old 11-01-2007, 08:17 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737
Look at "man test" ("[" is a synonym for "test")

-e is not for executable--it checks to see if the file exists
 
Old 11-01-2007, 08:28 AM   #3
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Original Poster
Rep: Reputation: 33
Thank you.

I did check man test.

its -w.
 
Old 10-25-2015, 02:14 AM   #4
Deus Absconditus
LQ Newbie
 
Registered: Sep 2015
Distribution: Arch Linux with xfce
Posts: 18

Rep: Reputation: Disabled
the existential -e test but what of -f ?

Quote:
Originally Posted by pixellany View Post
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?
 
Old 10-25-2015, 07:00 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,167

Rep: Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301
Bookmark this http://tldp.org/LDP/abs/html/fto.html - in fact read the whole doc
 
Old 10-25-2015, 11:56 PM   #6
Deus Absconditus
LQ Newbie
 
Registered: Sep 2015
Distribution: Arch Linux with xfce
Posts: 18

Rep: Reputation: Disabled
Wink

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[Shell] Read a File from script yussef Programming 4 08-19-2008 04:26 AM
How to read data from file to use in shell script? ozymandias Linux - Newbie 7 10-27-2006 01:19 PM
How to read a single line from a text file into a shell script. SkipHuffman Linux - Software 2 08-16-2006 02:10 PM
Shell script to read from csv file hendemeg Programming 1 05-11-2004 08:23 PM
How can I check wether a file is empty in Linux by using shell script programming ??? Bassam Linux - General 2 02-26-2004 01:01 AM


All times are GMT -5. The time now is 08:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration