The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Changing display and format of file wahi80 UNIX for Dummies Questions & Answers 1 08-02-2008 09:12 PM
To convert multi format file to a readable ascii format gaur.deepti UNIX for Dummies Questions & Answers 5 03-25-2008 03:03 PM
Convert UTF8 Format file to ANSI format rajreddy UNIX for Dummies Questions & Answers 9 05-25-2007 09:26 AM
sed to display date in dd/mm/yyyy format sars Shell Programming and Scripting 2 02-15-2007 03:32 AM
octal and strings strider High Level Programming 1 03-06-2006 10:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-12-2009
venkatesht venkatesht is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 69
Display permissions in octal format

Hi,

Is there any way to display the permissions in octal format rather than "rwxrwxrwx" format.

I have a file and i want to see the permissions in octal format. Please help.
  #2 (permalink)  
Old 02-12-2009
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,892
Code:
perl -e'printf "%o\n",(stat shift)[2]' filename
  #3 (permalink)  
Old 02-12-2009
supercops supercops is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 25
Quote:
Originally Posted by radoulov View Post
Code:
perl -e'printf "%o\n",(stat shift)[2]' filename
Okay this is working .

i checked one file with permissions -rw-r--r-- and this code is showing it as 100644.

Can any one explain what 100 means here ??
  #4 (permalink)  
Old 02-12-2009
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
  
 

Join Date: Dec 2007
Posts: 426
you need to add the bitwise AND

Code:
perl -e'printf "%o\n",(stat shift)[2] & 07777'

from the perldoc

Quote:
Because the mode contains both the file type and its
permissions, you should mask off the file type portion and
(s)printf using a "%o" if you want to see the real permissions.
  #5 (permalink)  
Old 02-13-2009
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,892
Quote:
Originally Posted by frank_rizzo View Post
you need to add the bitwise AND [...]
Right,
thanks for the correction!
  #6 (permalink)  
Old 02-13-2009
venkatesht venkatesht is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 69
Thanks a lot...

perl -e'printf "%o\n",(stat shift)[2] & 07777' ---- This is working.

But i donno perl. Is there anyway to achieve the same in unix.
  #7 (permalink)  
Old 02-13-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,285
On many Unix/Linuxes there is perl basically installed. Did you try it?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:44 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0