LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-19-2014, 06:09 PM   #1
Aidax
LQ Newbie
 
Registered: Jun 2014
Posts: 4

Rep: Reputation: Disabled
File Usage by User in GB?


Hi! I found this script on this website but I need to report into GB instead of KiloBytes!

I'm dealing with users who use terabytes at a time rather than little kilos!

Code:
find /net/netgear-3 -type f -printf '%u %k\n' | awk '{ arr[$1] += $2 } END { for ( i in arr ) { print i": "arr[i]"K" } }'

There's some commands I understand and others which I don't! I'm trying to dissect the script piece by piece to learn but that'll take some time.
 
Old 06-19-2014, 06:49 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
In the printf portion of the command, change %k to %G for gigabytes.
 
Old 06-19-2014, 07:25 PM   #3
Aidax
LQ Newbie
 
Registered: Jun 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
I've done that but the numbers are just as big or even skews them. I'll run an example!

Code:
~ Before ~
aaa: 38314876K
bbb: 977959528K
ccc: 3278940K
ddd: 50195788K
eee: 3145412K
fff: 14107620K
ggg: 1206414844K
hhh: 77784852K
iii: 4284456K
jjj: 0K
kkk: 544952K
lll: 137519616K
mmm: 137529564K
nnn: 1183194852K

~ After ~

aaa: 1264900GB
bbb: 58443392GB
ccc: 129258GB
ddd: 2000800GB
eee: 197340GB
fff: 675GB
ggg: 4252532GB
hhh: 24008248GB
iii: 10160GB
jjj: 698GB
kkk: 926240GB
lll: 0GB
mmm: 402016356GB
nnn: 225699096GB
Check out values for lll, jjj, or even kkk
 
Old 06-19-2014, 11:26 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,099

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
No, according to the manpage, that ain't what you want. Go back to "%k", and do the arithmetic yourself in the awk print command. Given that it's awk, you could add some logic to determine in G or T is more appropriate, but simple fix is
Code:
{ print i": "arr[i]/1024/1024"G" }
 
Old 06-19-2014, 11:37 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,099

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
Given the division(s), you'll get some ugly numbers out - here's a version that limits to 2 decimal places
Code:
 { printf "%s: %0.2f G\n",i,arr[i]/1024/1024 }
 
Old 06-20-2014, 03:55 PM   #6
Aidax
LQ Newbie
 
Registered: Jun 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks! that worked like a charm!
 
  


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
Bash script for listing FTP usage as the file name of a file created in each share jojothedogboy Programming 1 12-05-2008 03:35 PM
Memory usage per user logged in zQUEz Linux - Server 3 10-14-2008 06:20 AM
vsftp usage per user tajamari Linux - Software 1 06-13-2008 02:52 AM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
locking a usage policy file/ftp file permissions gbow Linux - Newbie 0 02-16-2004 05:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:07 AM.

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