Reputation: 61
I am creating report for usage of shared Linux nfs mount point and sending via email. I am using du
Linux command to get directory size but I need also to have information about who own these files. Is there a way to get information like this:
SIZE[MB] FILENAME OWNER 631746 /logs1 user1 372477 /logs2 user2 372477 /data3 user1 191846 /data2 user2
Thank You
Upvotes: 0
Views: 239
Reputation: 26501
Something along the lines of
for i in ./* # or however you get your filenames
do
printf '%s\t%s\n' "$(du -hs "$i")" "$(ls -ld "$i" | awk '{print $3}')"
done
will do it. Though the columns to be nicely aligned in (most/all) cases, it would require some more work.
Upvotes: 0
Reputation: 5300
Look into combining your commands with ls -l which will give user/group and other information, then pipe it to sed or cut for example and pipe on to output.
Upvotes: 0