#!/bin/sh umount /mnt/backup mount /dev/sdb1 /mnt/backup if [ `date +%d` = '01' ] #每月1號進行完全備份 then bakdir="/mnt/bak/daybak/month/"`date +%m%d` zl="" #進行完全備份 else backup_dir="/mnt/backup/"`date +%d` zl="-N "`date +'%Y-%m-01 00:00:01'`; #差異備份 #zl="-N "`date -d '-1 day' +'%Y-%m-%d 00:00:01'` #日增量備份 fi tar "${zl}" -czf ${backup_dir}/www.tgz /var/www umount /mnt/backup
例 22.12. random password
cat /dev/urandom | head -1 | md5sum | head -c 8 od -N 4 -t x4 /dev/random | head -1 | awk '{print $2}'
neo@debian:~/html/temp$ pidof lighttpd 2775 neo@debian:~/html/temp$ pgrep lighttpd 2775 neo@debian:~/html/temp$ pid=`pidof lighttpd` neo@debian:~/html/temp$ echo $pid 2775
# user=`whoami` # pgrep -u $user -f cassandra | xargs kill -9
kill 占用7800連接埠的進程
kill -9 `netstat -nlp | grep '192.168.0.5:7800' | awk -F ' ' '{print $7}' | awk -F '/' '{print $1}'`
echo "aaa bbb ccc" > test.txt echo "ddd eee fff" >> test.txt
for line in $(cat test.txt) do echo $line done
cat test.txt| while read line do echo $line done
perl - MEncode - pi - e ' $_=encode_utf8(decode(gb2312=>$_)) ' filename for f in `find .`; do [ -f $f ] && perl -MEncode -pi -e '$_=encode_utf8(decode(gb2312=>$_))' $f; done;
$ free | sed -n 2p | awk '{print "used="$3/$2*100"%","free="$4/$2*100"%"}' used=53.9682% free=46.0318%