LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 10-11-2009, 08:33 AM   #1
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,045

Rep: Reputation: 65
Question stat command to print permission in octal format


Is it possible to print the permission in octal format for a directory recursively?
Code:
stat -c "%a" /etc
It prints the permission for /etc directory only.
 
Old 10-11-2009, 10:09 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Try using find with -exec.

Code:
find /etc -exec stat -c "%a" '{}' \;
If you're using bash version 4 there's also a new ** recursive globbing function. But you have to enable it first.
Code:
shopt -s globstar

stat -c "%a" **
But find has an advantage in that you can use it to fine-tune the types of matches you want, such as using "-type d" to get directory permissions only.
 
Old 10-11-2009, 07:14 PM   #3
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,045

Original Poster
Rep: Reputation: 65
Solved.Thanks.

Last edited by cola; 10-11-2009 at 07:17 PM.
 
  


Reply



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
cannot stat: Permission denied. Why? Mountain Linux - Software 5 04-03-2008 12:50 PM
convert decimal to octal using the let command Suinatsa Programming 2 10-24-2006 08:42 AM
print files in PDF or html format from the linux command line IBKnobel Linux - Software 3 07-12-2004 09:29 PM
Octal format kawaii Linux - Newbie 2 11-02-2003 08:27 AM
the format of the date in stat in wrong rhuser Programming 9 03-16-2003 12:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:19 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
Open Source Consulting | Domain Registration