1 #!/bin/ksh 2 #set -x 3 # 4 #去掉文件中的^M 符号 5 # 6 usage() 7 { 8 echo "Usage : sh ToAscll.sh [Option] [value]" 9 echo "Option -path 文件目录" 10 echo "sh ToAscll.sh -path /batch/rjxf/YFZX20190328" 11 } 12 13 function readfile 14 { 15 filelist=`ls $2` 16 for file in $filelist 17 do 18 echo $2"/"$file 19 if [ -d $2"/"$file ];then 20 readfile 1 $2"/"$file 21 else 22 cat $2"/"$file | tr -d " " > $2"/"$file"_new" 23 rm -rf $2"/"$file 24 cp $2"/"$file"_new" $2"/"$file 25 rm -rf $2"/"$file"_new" 26 fi 27 done 28 } 29 30 FAIL=1 31 32 if [ $# -eq 0 ] 33 then 34 usage 35 exit $FAIL 36 37 fi 38 while [ 1 ] 39 do 40 case $1 in 41 "-path") 42 shift 1 43 JOB_CODE=$1 44 shift 1 45 ;; 46 *) 47 echo "[ERROR][$SHELL_CMD] 调用错误,参数不支持!" 48 usage 49 exit $FAIL 50 ;; 51 esac 52 53 if [ $# -eq 0 ] 54 then 55 break 56 fi 57 done 58 59 if [ -n "$JOB_CODE" ] 60 then 61 echo "start .............">>./logs.log 62 readfile 1 $JOB_CODE 63 else 64 echo "[ERROR][$SHELL_CMD] 调用错误,参数不支持!" 65 usage 66 exit $FAIL 67 fi
希望能够帮助有需要的小伙们O(∩_∩)O哈哈~