Help with file size script
At my university we have a disk space quota, so I used to just run du -sh * to see what was taking up space, but the problem was that hidden folders would not show up. To solve this I created a simple script to do it for all folders. My problem is that my script will not work on folders with spaces in the name. Can any some look it over and suggest a solution?
for file in `ls -a` do if [ $file != "." -a $file != ".." ]; then du -s $file fi #du -s $file done |
quick way, at the start change IFS variable to a newline exclusively
IFS=" " |
Wow, that was easy.
Thanks |
/* nevermind */
|
what about?
Code:
|
thats supposed to be
du -sh .* * looks like DOS *.* |
Another way:
find -exec du -hs {} \; |
That last one prints every single file. Bit of an overkill IMHO. For me the idea of "du" is to see a short list of the amount of data in the subdirs.
I use this in a script called "dusort" to produce a list of subdirs of the working dir sorted by size. Code:
du -s * | sort -g | cut -f 2 | xargs du -hs |
the problem with du -sh .* * is that it will also evaluate ..
|
you can use '-type d' to find only directories:
Code:
find . -type d -exec du -sh {} \; |
True, that's better.
|
All times are GMT -5. The time now is 12:44 PM. |