- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scipt that lists the amount of space by user
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 04:02 AM
тАО02-21-2005 04:02 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 04:06 AM
тАО02-21-2005 04:06 AM
Re: Scipt that lists the amount of space by user
on all the mount points or one directory?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 04:26 AM
тАО02-21-2005 04:26 AM
Re: Scipt that lists the amount of space by user
a FIRST attempt
#!/usr/bin/sh
user=$1
# Start at the root directory
cd /
# Find all entries owned by the user and extract the filesize
find . -user $user -exec ls -ld {} \; | awk -F' ' '{print $5}' > /tmp/$$
a=0
while read record
do
a=`expr $a + $record`
done < /tmp/$$
echo "User $user : $a bytes"
rm /tmp/$$
I'm sure perl has got a better way of adding up the bytes.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 04:53 AM
тАО02-21-2005 04:53 AM
Re: Scipt that lists the amount of space by user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 06:15 AM
тАО02-21-2005 06:15 AM
Re: Scipt that lists the amount of space by user
The following perl morcel with print the allocated space for each user in the current directory:
while (<*>) {
($u,$b)=(stat $_)[4,12];
$total{$u}+=$b;
}
foreach $u (sort keys %total) {
printf("%10s%6d%10d\n",
scalar getpwuid($u),$u,512*$total{$u});
}
cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 06:28 AM
тАО02-21-2005 06:28 AM
Re: Scipt that lists the amount of space by user
Does it include sub-directories in the current directory?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 07:04 AM
тАО02-21-2005 07:04 AM
Re: Scipt that lists the amount of space by user
Ah, no. You wrote 'directory', 'and all its's sub directories' :-).
I would enlist the help of the 'find' function:
use File::Find;
print "-".@ARGV."-\n";
sub add_blocks {($u,$b)=(stat $_)[4,12]; $total{"$u"}+=$b};
find (\&add_blocks, @ARGV);
foreach $u (sort keys %total) {
printf("%10s%6d%10d\n",
scalar getpwuid($u),$u,512*$total{$u});
}
Or... I might just go back to the find, or ls -lR command and deal with the output.
Hein,.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 07:07 AM
тАО02-21-2005 07:07 AM
SolutionArgh, I meant to write that you originally did not write "and it's subdirectory", just "directory".
And I posted a test version.
And I did not give usage instructions:
perl allocated_by_user /some_top_dir [/more_directories]
------- allocated_by_user -----
use File::Find;
sub add_blocks {($u,$b)=(stat $_)[4,12]; $total{"$u"}+=$b};
find (\&add_blocks, @ARGV);
foreach $u (sort keys %total) {
printf("%10s10d\n",
scalar getpwuid($u),512*$total{$u});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 12:05 PM
тАО02-21-2005 12:05 PM
Re: Scipt that lists the amount of space by user
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2005 09:45 PM
тАО02-21-2005 09:45 PM
Re: Scipt that lists the amount of space by user
cd /home
du -sk *|sort -n > naughtyusers.txt