LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Restricting 'du' to child directories only? (http://www.linuxquestions.org/questions/linux-general-1/restricting-du-to-child-directories-only-862858/)

daweefolk 02-15-2011 11:11 AM

Restricting 'du' to child directories only?
 
I'm trying to write a script that uses the 'du' command to make essentially a text-based filelight type program.
It should scan the current directory for the file's sizes and display them in order largest to smallest (or vice versa). The user should be able to go throughout the file tree and see child directories scanned for the sizes as they're accessed.
I just need to know one more thing- how can I restrict the displayed results to the current working directory? would a grep for the output of pwd suffice? just getting some thoughts before i try and possibly dig myself a hole.

bigrigdriver 02-15-2011 01:31 PM

You can use the ls command, with options for long listing, recursive search, sort by file size, current working directory: ls -lRS $PWD

You can then pipe the results through awk to show only the fields of interest in the output.


All times are GMT -5. The time now is 02:08 AM.