SSH (Commercial) Mirror



Removing leading zero using awk

Had to extract data from rrdtool and feed it to Zabbix. Problem was I kept getting leading zero variables. This removes any leading zero:

rrdtool fetch lighttpd.rrd AVERAGE -s -60s \
| grep -v nan \
| grep -v Requests \
| awk '{printf "%d",$2}' \
| awk '{print $1 + 0}'

to test it yourself:

echo 000000105 | awk '{ print $1 + 0}'


Look for folders with world write bit on

$FIND $DIRNAME -xdev -perm +o=w ! \( -type d -perm +o=t \) ! -type l -print

Look for scripts with setuid on

$FIND $DIRNAME -xdev -type f -perm +u=s -print

Find all superuser accounts

grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}'

Delete old files on lighttpd cache

find ${CROOT} -type f -mtime +${DAYS} -delete

rename files to lowercase

lowercase=$(echo $file | tr '[A-Z]' '[a-z]'])

Delete even/odd lines on a text file

sed ā€˜0~2dā€™ -i file

Count number of files in each directory

find -type f -execdir pwd \; | sort | uniq -c