LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 08-23-2012, 06:38 AM   #1
fbraphael
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, 08:22 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,870
Blog Entries: 14

Rep: Reputation: 1112Reputation: 1112Reputation: 1112Reputation: 1112Reputation: 1112Reputation: 1112Reputation: 1112Reputation: 1112Reputation: 1112
Code:
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, 03:31 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,121

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
single process:
Code:
find . -type d -exec stat '{}' \;
 
Old 08-23-2012, 03: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: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959
If you're using a relatively recent version of bash, you can use the new globstar globbing feature.

Code:
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.
 
  


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 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 12:33 PM
cp -r in subfolders??? c0nsur Linux - General 2 03-10-2006 10:28 AM
IMAP Subfolders keithk23 Linux - Software 4 01-26-2005 08:49 AM
Linux stat to Windows Stat sridurai Programming 3 09-24-2004 04:07 PM
Mozilla 1.6 can't create subfolders porty Linux - Software 0 05-19-2004 01:48 PM


All times are GMT -5. The time now is 12:22 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration