Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-01-2007, 08:09 AM   #1
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

if [-e filename]

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

Old 11-01-2007, 08:17 AM   #2
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735
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
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Original Poster
Rep: Reputation: 33
Thank you.

I did check man test.

its -w.


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 10:41 PM.

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