0

I am checking the file sizes of /tmp directory using du -h, but I also would like to have the ownership information of those files. There is a simple way to do this? I looked at the du manual and it seems to not have any option for this.

Thank's in advance.

  • 1
    `du` doesn't support sorting or analyzing disk usage by user. Look here: https://superuser.com/questions/597168/total-disk-usage-for-a-particular-user – LawrenceC Mar 31 '17 at 14:02
  • It can be done (but not simply) by filtering the output of each line, so as to add extra information about each file to the `du` output. If you're saving the results to a file, this is fine, but on the console the lines will not be generated in real time, because of pipe buffering (which you can disable at the cost of even more complexity). If this is of interest, I can put a script outline in an answer, but it's too complex for a comment. – AFH Mar 31 '17 at 14:48
  • I was hoping someone had some killer script done in their bashrc or something like that. One way of doing this is to paste the output of recursive `ls` and `du`, assuming that the output of those two commands are sorted in the same way. – Jonatas Eduardo Mar 31 '17 at 14:58

1 Answers1

1

You can use the following command and have a check .

stat -c "%y %s %n" /tmp/*

  • 2
    Can you add a couple of sentences to the answer to elaborate on the command parameters, what they do, and what this does to solve the question? The answer showed up in the [review queue](https://superuser.com/review/low-quality-posts/640524) because the objective is answers that educate rather than just unexplained commands or code. Thanks. – fixer1234 Apr 02 '17 at 21:57
  • Since I want the user information I looked at stat manual (great linux command by the way), and the options I want are `stat -c %y %s %U:%G %n`. The only problem is that stat don't have any options do look inside each directory in /tmp, whereas `du` has `--max-depth=N`. – Jonatas Eduardo Apr 04 '17 at 12:16