Share your knowledge at the LQ Wiki.
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 08-23-2012, 07:38 AM   #1
LQ Newbie
Registered: Aug 2012
Posts: 1

Rep: Reputation: Disabled
stat on subfolders?

Is it possible to run the stat command and see the permissions for the current folder and all subfolders? Thanks!
Old 08-23-2012, 09:22 AM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,679
Blog Entries: 14

Rep: Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021
find . -type d |xargs stat
The "find . -type d" says to search the current directory and and show all subdirectories. This output is piped into xargs which says to run a command on every line of output so it runs the stat on each subdirectory from the find.
Old 08-23-2012, 04:31 PM   #3
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
single process:
find . -type d -exec stat '{}' \;
Old 08-23-2012, 04:41 PM   #4
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958
If you're using a relatively recent version of bash, you can use the new globstar globbing feature.

shopt -s globstar
stat --printf='%A: %n\n' **/
** expands to all files recursively.
**/ expands to directories only.
You can append another globbing pattern after it to expand to certain files inside those directories.

Don't use it on any tree that contains recursive directory symlinks, however.

You'll also want to enable the dotglob option to expand hidden files.


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
[SOLVED] gcc linker error - hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) chaosless Linux - Software 1 09-17-2009 01:33 PM
cp -r in subfolders??? c0nsur Linux - General 2 03-10-2006 11:28 AM
IMAP Subfolders keithk23 Linux - Software 4 01-26-2005 09:49 AM
Linux stat to Windows Stat sridurai Programming 3 09-24-2004 05:07 PM
Mozilla 1.6 can't create subfolders porty Linux - Software 0 05-19-2004 02:48 PM

All times are GMT -5. The time now is 04:57 AM.

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