LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-20-2005, 11:42 AM   #1
xgreen
Member
 
Registered: Aug 2003
Distribution: Slackware,Arch
Posts: 389

Rep: Reputation: 30
BASH : Total directory size


hi

i need to get the size of one directory but with "du -m |awk '{print $1}' " i got it including the sub directories. In the case below i need only "23" as a output..

nazmin@darkstar:/windows/shared/working_iso$ du -m |awk '{print $1}'
2
1
1
1
16
2
2
1
2
1
1
22
22
22
22
23
23
 
Old 04-20-2005, 11:57 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Why not pipe it through tail -1?
 
Old 04-20-2005, 12:03 PM   #3
xgreen
Member
 
Registered: Aug 2003
Distribution: Slackware,Arch
Posts: 389

Original Poster
Rep: Reputation: 30
not working...thanx

nazmin@darkstar:/windows/shared/working_iso$ du -m iso_dir/ | tail -l
2 iso_dir/pythontut/python.org/doc/2.4/ref
1 iso_dir/pythontut/python.org/doc/2.4/tut
2 iso_dir/pythontut/python.org/doc/2.4/dist
1 iso_dir/pythontut/python.org/doc/2.4/inst
1 iso_dir/pythontut/python.org/doc/2.4/icons
22 iso_dir/pythontut/python.org/doc/2.4
22 iso_dir/pythontut/python.org/doc
22 iso_dir/pythontut/python.org
22 iso_dir/pythontut
23 iso_dir/
nazmin@darkstar:/windows/shared/working_iso$
 
Old 04-20-2005, 12:36 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
How about du -sh
 
Old 04-20-2005, 12:49 PM   #5
xgreen
Member
 
Registered: Aug 2003
Distribution: Slackware,Arch
Posts: 389

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by homey
How about du -sh
ah...perfect...

i should "man du" first....:-P

thanx
 
Old 03-16-2010, 02:26 AM   #6
rodrigomilfont
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by xgreen View Post
ah...perfect...

i should "man du" first....:-P

thanx
"du...de, mannnnn, duude..." LOL
 
Old 03-16-2010, 11:13 AM   #7
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Quote:
Originally Posted by rodrigomilfont View Post
"du...de, mannnnn, duude..." LOL
Your first post ever on LQ and this is the best you can do? A pointless comment to a 5 year old post. If your intention is to try out a test post, feel free to introduce yourself in the new member forum:

http://www.linuxquestions.org/questi...mber-intro-24/
 
Old 03-04-2013, 05:33 AM   #8
Appastair
LQ Newbie
 
Registered: Mar 2013
Posts: 1

Rep: Reputation: Disabled
Lightbulb

Quote:
Originally Posted by crabboy View Post
Your first post ever on LQ and this is the best you can do? A pointless comment to a 5 year old post.
I thought it was funny and noone got hurt.

Back on topic though: I didn't know of sort or its options but to list it will list input in reverse, numeric order. With the du prepending directories' sizes, it saves a lot of skimming, if, for example, you're looking for the first 5 directories using the most storage.

Code:
du ./* -d 0  -m | sort -nr | head -n 5
Quote:
56102 ./Black Metal
7405 ./Alternative
5424 ./Sognametal
1991 ./Soundtrack
697 ./Classical

Last edited by Appastair; 03-04-2013 at 05:34 AM. Reason: grammar... -_-
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
finding size of total files in a directory blackzone Linux - Newbie 3 01-07-2005 03:01 AM
Urgent !!! monitoring directory size using bash juby Programming 4 07-22-2004 05:47 AM
Total partition size - User partition size is not equals to Free partition size navaneethanj Linux - General 5 06-14-2004 12:55 PM
Total File Size meshcurrent Linux - General 1 05-17-2004 02:09 PM
How to list total file size of a directory phil1076 Linux - General 3 12-18-2003 03:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration