Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 02-15-2011, 11:11 AM   #1
Registered: Sep 2009
Distribution: debian
Posts: 84

Rep: Reputation: 15
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.
Old 02-15-2011, 01:31 PM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,893

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
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.

Last edited by bigrigdriver; 02-15-2011 at 01:33 PM.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Child THREAD and Child PROCESS whho Linux - Newbie 12 02-16-2015 12:22 AM
Restricting users to two directories Centos 5.3 thebomb Linux - Server 1 02-16-2010 01:01 AM
How to kill a Child and all its subsequent child process in C shayer009 Programming 3 12-04-2007 12:40 AM
chroot jail with rssh / restricting users to individual directories rob_xx17 Linux - Security 3 01-23-2006 03:28 AM
Killing a child process from another child marri Programming 6 10-01-2004 07:08 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:20 PM.

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