How to use du
command show a slash after directories?
For example:
du -ab /root/test/php-5.4.8/
Result:
1781 /root/test/php-5.4.8/main/internal_functions.c.in
973596 /root/test/php-5.4.8/main
3841 /root/test/php-5.4.8/netware/start.c
577 /root/test/php-5.4.8/netware/sendmail_nw.h
8514 /root/test/php-5.4.8/netware
4957 /root/test/php-5.4.8/README.TESTING2
4561 /root/test/php-5.4.8/.gitignore
However I want directories to include trailing slash, for example:
1781 /root/test/php-5.4.8/main/internal_functions.c.in
973596 /root/test/php-5.4.8/main/
3841 /root/test/php-5.4.8/netware/start.c
577 /root/test/php-5.4.8/netware/sendmail_nw.h
8514 /root/test/php-5.4.8/netware/
4957 /root/test/php-5.4.8/README.TESTING2
4561 /root/test/php-5.4.8/.gitignore
I have managed to do find
command but it will not include total file size of the directories and that is why I have to use du
command
find /root/test/php-5.4.8/ \( -type d -printf "%s %p/\n" , -type f -printf "%s " -print \)
Best Answer
Just make it work with a little bash scripting. Print the size and filename, if it is a directory add a trailing slash.
This will work with any file name not containing newlines or ending with a tab.