bash

size and count documento older then

find -type f -mtime +165 -exec ls -al {} \; | awk 'BEGIN {count = 0} {count++;  sum += $5} END {sum = sum/1024000000; print "GB " sum " numero documenti " count}'

add public key with only one command (pay attention of authorized_keys permission. only owner must have write access, so before issue: chmod 644):

cat id_rsa.pub | ssh -l davide davidedoro.it "cat >> .ssh/authorized_keys"

useful create a zabbix import file

ddoro@asdasd /c/job/repo/scripts/bash (master)
$ while read i h l; do sed "s/\#ip\#/$i/g;s/\#host\#/$h/g" template; done < hosts >> template.xml

bash ping for

for i in {10..50}; do for j in {31..37}; do ip=X.Y.$i.$j; fping -t 50 $ip ; if [ $? -eq 0 ]; then echo $ip >> file; fi; done; done
for i in {139}; do for j in {31..37}; do ip=X.Y.$i.$j; fping -t 50 $ip ; if [ $? -eq 0 ]; then echo $ip >> file; fi; done; done

zip encrypted

zip -e file.zip list of files
the -e asks for the encryption password.

script to check mtu using ping command

for i in {1360..1400}; 
    do echo $i; 
    ping -M do -s $i -c 1 -W 1 172.20.11.11;
    if [ $? -ne 0 ]; 
        then echo -e "\n===== $i =====\n\n"; 
        break ; 
    fi ; 
done