LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-08-2010, 10:06 AM   #1
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Rep: Reputation: 39
Question show permission in octal notation?


'ls -l' gives me the permissions in the long format - drwxr-xr-x format. Is there a way i can get the permissions in a form i can use in a bash script? the only form i can imagine of is the octal one... something like '755' for the above, but i dont know what would give me such an output.... are there other methods to consider while using (rather comparing) them in a script?
 
Old 02-08-2010, 10:24 AM   #2
nicedream
Member
 
Registered: Feb 2010
Distribution: Arch Linux
Posts: 68

Rep: Reputation: 19
Try looking at the "stat" command.
 
1 members found this post helpful.
Old 02-08-2010, 06:12 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,267

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
You can use the symbolic notation in a script eg

chmod u+rw file

ie adds r,w perms to file
 
Old 02-09-2010, 04:39 AM   #4
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by nicedream View Post
Try looking at the "stat" command.
Hey thanks! stat does it!
Code:
stat --format=%a testfile
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] stat command to print permission in octal format cola Linux - General 2 10-11-2009 07:14 PM
show the permission of '/usr' mount point in AIX 5.3 shipon_97 AIX 1 11-19-2008 06:51 AM
pointer notation vs array notation? pablowablo Programming 5 03-14-2005 12:34 PM
Octal format kawaii Linux - Newbie 2 11-02-2003 08:27 AM
how to show file permission ? juanb Linux - Newbie 2 08-19-2003 10:01 AM


All times are GMT -5. The time now is 03:02 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration