Find the answer to your Linux question:
Results 1 to 3 of 3
Hi All, I have a directory which is extremely large and I would like to exclude this directory while doing a "du" I tried the following .. du -ks --exclude="DIR_PATTERN" ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    2

    Excluding a directory from "du" command

    Hi All,

    I have a directory which is extremely large and I would like to exclude this directory while doing a "du"

    I tried the following ..

    du -ks --exclude="DIR_PATTERN" *

    - This works if the size of the directory is small ..
    - However, if the size is extremely large, it still tries to calculate the size, before excluding from the output, and this takes forever.


    Q: How do I exclude a directory from du?

    OS is RHEL 3.0 Update9


    - RHEL noob

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    welcome to the forum

    trying "du --exclude=pix" I got a listing that excluded that directory.
    it is 27gigs. Why you need -k" I'm not sure: it's the default.
    the sun is new every day (heraclitus)

  3. #3
    Just Joined!
    Join Date
    Feb 2009
    Posts
    2
    the directory resides on a NAS filer and is probably greater than 50G in size ..

    though we mention an exclude list, the du is still trying to calculate the size .. and then excludes from the display ..

    I got the following recommendation from one of my colleagues .. I still haven't tested it yet ..
    ---------------------------------------------
    #ls -F|grep />/tmp/l2
    #vi /tmp/l2 (remove the directory you have to exclude)

    #for i in `cat /tmp/l2`
    do
    du -hs $i > /var/tmp/du_lisiting.out
    done
    ---------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...