飞花逐月(平) 发表于 2013-2-1 09:48:54

文件自动解压

#!/bin/bashinotifywait -rm -e CLOSE_WRITE /root | while read file; do       file_full_name=`echo "$file" | awk '{print $1$3}'`       file_path=`echo "$file" | awk '{print $1}'`       file_path_count=`echo "$file_path" | tr -cd '/' | wc -c`       if [ -f $file_full_name -a $file_path_count = 4 ]; then         file_ext_name=`echo ${file:0-3:3}`         if [ $file_ext_name = "zip" ]; then         echo "--------------------------------" >> /home/lxp/my_shell/log/log_auto_extract         echo "--------------------------------" >> /home/lxp/my_shell/log/log_auto_extract         date +"%Y-%m-%d %H:%M:%S" >> /home/lxp/my_shell/log/log_auto_extract         unzip -o $file_full_name -d $file_path >> /home/lxp/my_shell/log/log_auto_extract 2>&1         fi       fidone
页: [1]
查看完整版本: 文件自动解压