LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:55 AM.

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