LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   du -hx (https://www.linuxquestions.org/questions/linux-newbie-8/du-hx-4175466725/)

rookie11 06-20-2013 06:18 AM

du -hx
 
du -hx /dir or mountpoint will display all the subsequent directories and their size. e.g
8.0K /usr/share/locale/got/LC_MESSAGES
8.0K /usr/share/locale/ie/LC_MESSAGES
8.0K /usr/share/locale/fiu/LC_MESSAGES
8.0K /usr/share/locale/kaa/LC_MESSAGES
7.8M /usr/share/locale/fr/LC_MESSAGES
8.0K /usr/share/locale/ii/LC_MESSAGES
96K /usr/share/locale/es_PR/LC_MESSAGES

I want use command du -hx /dir then grep output of dir whose size is in Gb or G. Plz tell me how to do it.

Madhu Desai 06-20-2013 06:44 AM

Code:

# du -hx /dir/ | sort -h | grep -i '^[0-9]*\.\?[0-9]*G'
gnu grep:
Code:

# du -hx /dir/ | sort -h | grep -Ei '^[0-9]*.?[0-9]*G'
# du -hx /dir/ | sort -h | grep -Ei '^[[:digit:]]*.?[[:digit:]]*G'

perl style:
Code:

# du -hx /dir/ | sort -h | grep -Pi '^\d*.?\d*G'

jitendra.sharma 06-20-2013 06:56 AM

Why you want use du -hx /dir you can use simple #du -hs /dir command for the size in GB and MB.


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