[phpBB Debug] PHP Notice: in file /viewtopic.php on line 981: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead
[phpBB Debug] PHP Notice: in file /viewtopic.php on line 981: getdate(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead
Tynsoe Projects • View topic - Trash size and number of items

Trash size and number of items

Trash size and number of items

Postby Peter G » Sat Nov 13, 2010 3:10 am

This script gives you the number of items in the Trash, as well as the trash size:

Code: Select all
du -sh ~/.Trash/ | awk '{print "Trash: " $1}'; ls -l ~/.trash | wc -l |awk '{(contents = $1-1); if (contents <0) print "Trash empty"; else print contents " item(s)"}'


The Unix word count command wc -l counts the number of items in the .Trash directory, and the -l switch makes it count lines instead of words. Because the ls command lists the directory size as well as the contents it is necessary to subtract 1 from the variable "contents" to get the correct number of items. This gives a value of -1 to "contents" when the trash is empty, hence the expression if (contents <0).

Obviously, this script can be adapted to count items in other directories than Trash, so please post anything you derive from this.

Also, is it possible to put the Trash size and number of items on the same line?
Peter G
 
Posts: 1
Joined: Sat Nov 13, 2010 2:46 am

Re: Trash size and number of items

Postby ybizeul » Sat Nov 13, 2010 9:48 am

Hi Peter, thanks for sharing.

Here is my thought :
Code: Select all
echo -n "Trash: "`du -sh ~/.Trash|awk '{ print $1 }'`;C=`ls -1 ~/.Trash|wc -l|xargs`; if [ "$C" == "0" ]; then echo " Trash empty"; else echo " contents $C items";fi
ybizeul
Site Admin
 
Posts: 133
Joined: Fri Jan 22, 2010 4:34 pm


Return to GeekTool

Who is online

Users browsing this forum: No registered users and 1 guest

cron