LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 02-04-2014, 08:12 PM   #1
kenw232
Member
 
Registered: May 2006
Posts: 44

Rep: Reputation: 0
Best directory size report command?


I'm trying to get a quick overview of my web folder sizes.
like /var/http/www.whatever.com

I was using something like
du -sk * | sort -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'

to get report like
848.0K www.whatever.com
1.4M www.whatever2.com

but that command does not work on my new slackware 14.1 server now. It was fine on my older slackware 10 server.

Does anyone have any suggestions on something that can generate a report like that? also sorted?
 
Old 02-04-2014, 08:14 PM   #2
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 2,625

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Why not du -h ?
 
Old 02-04-2014, 08:32 PM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

Rep: Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096
I usually use ncdu for tasks like that. It is an interactive tool, but when used with the -o option it will save a report to a file that can later be opened with ncdu using the -f option.
 
1 members found this post helpful.
Old 02-04-2014, 09:05 PM   #4
bosth
Member
 
Registered: Apr 2011
Posts: 235

Rep: Reputation: 68
du -sh *
 
Old 02-04-2014, 09:36 PM   #5
qweasd
Member
 
Registered: May 2010
Posts: 486

Rep: Reputation: Disabled
du is great, and so is filelight
 
Old 02-04-2014, 10:13 PM   #6
kenw232
Member
 
Registered: May 2006
Posts: 44

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TobiSGD View Post
I usually use ncdu for tasks like that. It is an interactive tool, but when used with the -o option it will save a report to a file that can later be opened with ncdu using the -f option.
Can Ncdu output just a raw text report?
 
Old 02-05-2014, 02:21 AM   #7
lems
Member
 
Registered: May 2004
Distribution: Slackware x86/x86_64/ARM, NetBSD
Posts: 165

Rep: Reputation: 56
There is also a small utility called dirsize. Its primary purpose is for use with shell prompts, but can be used as a stand-alone program as well. From the web site:
Quote:
This tool outputs the aggregate size of all files in one or more directories, defaulting to the current directory. It does not recurse.
So it might not be exactly what you're looking for.
 
Old 02-05-2014, 04:45 AM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

Rep: Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096Reputation: 4096
Quote:
Originally Posted by kenw232 View Post
Can Ncdu output just a raw text report?
Those reports are raw text and contain filename, real size, size on disk and inode number. Here is an example, run on my /etc/slackpkg directory:
Code:
[1,0,{"progname":"ncdu","progver":"1.10","timestamp":1391593344},
[{"name":"/etc/slackpkg","asize":4096,"dsize":8192,"dev":2049,"ino":6333},
{"name":"blacklist","asize":1021,"dsize":4096,"ino":1227235},
{"name":"blacklist~","asize":1004,"dsize":4096,"ino":1135329},
{"name":"greylist","asize":543,"dsize":4096,"ino":7156},
{"name":"mirrors","asize":25508,"dsize":28672,"ino":1773597},
{"name":"mirrors~","asize":25511,"dsize":28672,"ino":7685},
{"name":"notifymsg.conf","asize":1750,"dsize":4096,"ino":7069},
{"name":"slackpkg.conf","asize":5893,"dsize":8192,"ino":7687},
{"name":"slackpkg.conf~","asize":5894,"dsize":8192,"ino":7688},
{"name":"slackpkgplus.conf","asize":4459,"dsize":8192,"ino":1773592},
{"name":"slackpkgplus.conf.new~","asize":5136,"dsize":8192,"ino":445708},
{"name":"slackpkgplus.conf.orig","asize":2259,"dsize":4096,"ino":507979},
{"name":"slackpkgplus.conf~","asize":4488,"dsize":8192,"ino":6349},
[{"name":"templates","asize":1,"ino":13813}]]]
 
Old 02-05-2014, 09:05 AM   #9
NoStressHQ
Member
 
Registered: Apr 2010
Location: Lausanne - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware Leet - 32/64bit
Posts: 317

Rep: Reputation: 109Reputation: 109
Quote:
Originally Posted by kenw232 View Post
Can Ncdu output just a raw text report?
ncdu is "just" a ncurse gui over du... So to output text, just use du...
 
Old 02-05-2014, 09:56 AM   #10
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,624
Blog Entries: 1

Rep: Reputation: Disabled
I've used this for years:
Code:
#!/bin/bash
/usr/bin/du -sk ./* | /usr/bin/sort -n | /usr/bin/awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'
outputs similar to:
Code:
12K	./Desktop
14.2M	./wun
51M	./Bin
171.1M	./Pictures
17.5G	./Documents
26.5G	./Downloads
32.3G	./VboxVMs
Total: 74.7G
Edit: Obviously, I ran this in my ~ directory - YMMV

Last edited by Habitual; 02-05-2014 at 10:56 AM.
 
2 members found this post helpful.
Old 02-05-2014, 10:02 AM   #11
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,159

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
this is already implemented (total is not included):
du -sh * | sort -h
 
Old 02-05-2014, 02:32 PM   #12
kenw232
Member
 
Registered: May 2006
Posts: 44

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by lems View Post
There is also a small utility called dirsize. Its primary purpose is for use with shell prompts, but can be used as a stand-alone program as well. From the web site:
So it might not be exactly what you're looking for.
dirsize is nice but I'm not smart enough to sort it by size. dirsize -H * | sort -n doesn't cut it?
 
Old 02-05-2014, 02:35 PM   #13
kenw232
Member
 
Registered: May 2006
Posts: 44

Original Poster
Rep: Reputation: 0
Code:
#!/bin/bash
/usr/bin/du -sk ./* | /usr/bin/sort -n | /usr/bin/awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'
This is a good replacement for my problem. Thanks.
 
Old 02-05-2014, 02:47 PM   #14
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,624
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by kenw232 View Post
Code:
#!/bin/bash
/usr/bin/du -sk ./* | /usr/bin/sort -n | /usr/bin/awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'
This is a good replacement for my problem. Thanks.
Glad you like it and it helps you out.
 
  


Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimum file size to report a size in vsftpd log rjo98 Linux - Server 1 10-12-2011 07:24 PM
[SOLVED] Directory contents, size ect from the command line Atomiccomp02 Linux - Newbie 2 06-15-2011 06:26 PM
command to split up directory by size? dr_zayus69 Programming 6 06-27-2005 04:12 AM
A simple command displaying the size of a directory satimis Linux - Newbie 5 11-24-2004 01:06 AM
redhat command to display the size of directory please! sandrinechen Linux - Newbie 4 04-19-2004 04:19 AM


All times are GMT -5. The time now is 04:00 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration