Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

How to list all files in dir and sub-dir's recursively along with file size?

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-28-2010
nmakkena nmakkena is offline
Registered User
 
Join Date: Oct 2010
Last Activity: 20 November 2011, 10:20 PM EST
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
How to list all files in dir and sub-dir's recursively along with file size?

I am very new to unix as well as shell scripting.
I have to write a script for the following requirement. In have to list all the files in directory and its sub directories along with file path and size of the file
Please help me in this regard and many thanks in advance.
Sponsored Links
    #2  
Old Unix and Linux 10-28-2010
zaxxon's Unix or Linux Image
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 20 October 2017, 2:49 AM EDT
Location: St. Gallen, Switzerland
Posts: 6,575
Thanks: 176
Thanked 560 Times in 481 Posts
If your find supports the -ls switch, you could do something like this:

Code:
find . -type f -ls| awk '{print $7,$NF}'

If there are blanks in the file names, there could be missing something though.

If the -ls switch is not supported, you could use

Code:
find .... -exec ls {} \; awk ....

or if there is the possibility for your ls to tell it which format it should have, to define that you only need the size and filename.
Sponsored Links
    #3  
Old Unix and Linux 10-28-2010
Ygor's Unix or Linux Image
Ygor Ygor is offline Forum Advisor  
Advisor
 
Join Date: Oct 2003
Last Activity: 15 May 2015, 11:55 AM EDT
Location: 54.23, -4.53
Posts: 1,801
Thanks: 1
Thanked 114 Times in 99 Posts
The du command prints size and filename, so maybe try...
Code:
find . -type f -exec du -b {} \+

    #4  
Old Unix and Linux 10-28-2010
abinaya abinaya is offline
Registered User
 
Join Date: Apr 2009
Last Activity: 2 September 2011, 5:03 AM EDT
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Try this ls -lR
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
list the files with size in bytes balireddy_77 Shell Programming and Scripting 4 01-06-2009 12:17 PM
Number of open files (Dir's) how to close? satyam90 UNIX for Advanced & Expert Users 1 11-07-2008 08:17 AM
Files list which are more than 300 MB size redlotus72 UNIX for Dummies Questions & Answers 2 09-14-2006 12:28 AM
List Files Recursively roberthawke UNIX for Dummies Questions & Answers 9 06-24-2002 06:19 PM



All times are GMT -4. The time now is 04:03 PM.