понедельник, 24 октября 2011 г.

bash

bash last day of month
$LASTDAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`


count files number, if "argument list too long"
# find . -name "*.php_expire" | wc -l

# find . -name "*.php_expire" | xargs rm

# touch -t MMDDhhmm date

# find . ! -newer date -name "*.php" | xargs rm

add to tar + gzip
# cd /dir1/dir2
# tar -czvf arcname.tgz dir3
extract
# cd /dir1/dir2
# tar -xzvf arcname.tgz

find file in date range ant tar
# find . -newer from_date ! -newer to_date | xargs tar -czvf arcname.tgz {}

file without comments and blank lines
#cat file | grep -v '^#' | sed '/^$/d'