LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 09:33 AM   #1
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,047

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, 11: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, 08:14 PM   #3
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,047

Original Poster
Rep: Reputation: 65
Solved.Thanks.

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


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

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

All times are GMT -5. The time now is 08:52 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