Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Display the size of the trash prior to emptying' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Display the size of the trash prior to emptying
Authored by: sophistry on Feb 28, '03 02:22:10PM

You can convert the kilos into megas using this expanded unix
command. It's actually just useful to show a few shell techniques like
command substitution and formatting strings to send to bc.

do command substitution on the du command to get it into printf to
format a stream suitable to send to bc. notice the use of cut rather than
awk '{print $1}' since it is a simpler tool for the job.

printf 'scale=2;%s/1024\n' `du -sk ~/.trash | awk '{print $1}'` | bc -l
versus
printf 'scale=2;%s/1024\n' `du -sk ~/.trash | cut -f1` | bc -l

note: using single quotes for surrounding the printf string in case you
want to use this in an applescript.



[ Reply to This | # ]
update: Display the size of the trash prior to emptying
Authored by: sophistry on Feb 28, '03 02:27:59PM

I just realized a simple way to get the MB reading is to just use the built-
in ability of awk to do lots of amazing things that you alwys forget about:

du -sk ~/.trash | awk '{print $1/1024}'

does the trick.



[ Reply to This | # ]