1. 併發備份數據庫mysql
#!/bin/bashsql exec &> /tmp/mysql_bak.log數據庫 if ! which innobackupex &>/dev/nll bakdir=/data/backup/mysql function bak_data { fifofile=/tmp/$$ ## 這個腳本運行的pid thread=10 cat /tmp/databases.list | while read line wait |
2. 打印三角形
3. 截取字符串
4. 修改文本格式
5. 自定義rm
#!/bin/bash filename=$1 if [ ! -e $1 ] d=`date +%Y%m%d%H%M` if [ $f_size -lt $disk_size ]then read -p "Are U sure delete the file or directory: $1? y|n: " c case $c in y|Y) mkdir -p $big_filesystem/.$d && rsync -aR $1 $big_filesystem/.$d/$1 && /bin/rm -rf $1 ;; n|N) exit 0 ;; *) echo "Please input 'y' or 'n'." ;; esacelse echo "The disk size is not enough to backup the files $1." read -p "Do you want to delete $1? y|n: " c case $c in y|Y) echo "It will delete $1 after 5 seconds whitout backup." for i in `seq 1 5`; do echo -ne ". "; sleep 1;done echo /bin/rm -rf $1 ;; n|N) echo "It will not delete $1." exit 0 ;; *) echo "Please input 'y' or 'n'." ;; esacfi |