try

来自「ksh 实现的基于hpux下的性能数据以及故障的采集程序。可以作为新手练手使用」· 代码 · 共 76 行

TXT
76
字号
#!/bin/kshfor i  in `ls -1 *.fmt | sed 's/^.*_.*_.*_\(.*\).fmt/\1/' | sort -k 1 | uniq`do  funcName=`ls [IO]*${i}*.fmt | sed 's/^\(.*\)_\(.*\)_\(.*\)_\(.*\).fmt/\2_\3_\4/' | head -1`   instName=HPUX  inputFile=`ls [IO]*${i}*.fmt | sed -e 's/^\(.*\)_\(.*\)_\(.*\)_\(.*\).fmt/I_\2_\3_\4_${TMSTAMP}.txt/' | head -1`  inputFmt=`ls [IO]*${i}*.fmt | sed -e 's/^\(.*\)_\(.*\)_\(.*\)_\(.*\).fmt/I_\2_\3_\4.fmt/' | head -1`  outFile=`ls [IO]*${i}*.fmt | sed -e 's/^\(.*\)_\(.*\)_\(.*\)_\(.*\).fmt/O_\2_\3_\4_${TMSTAMP}.txt/' | head -1`  outFmt=`ls [IO]*${i}*.fmt | sed -e 's/^\(.*\)_\(.*\)_\(.*\)_\(.*\).fmt/O_\2_\3_\4.fmt/' | head -1`  descFile=../desc/${i}desc.txt  cat <<EOF > $descFile功能全称 ${funcName}适用平台或实例 ${instName}输入文件 $inputFile输出文件 $outFile EOFecho "输入文件内容" >> $descFileif [[ -s $inputFmt ]] then  sqno=1  while read -r f1 f2 rest  do    if [[ ${#f1} = 0 ]] then       continue    fi    if [[ `expr "$f1" : '#.*'` > 0 ]] then       continue    fi    if (( sqno == 1 )) then      echo "序号 中文名称 英文名称 备注" >> $descFile    fi    echo "$sqno ${f1} ${f2}" >> $descFile    (( sqno = sqno + 1 ))  done < $inputFmt  if (( sqno == 1 )) then    echo "N/A"  >> $descFile  fi  echo "" >> $descFileelse  echo "N/A"  >> $descFilefiecho "输出文件内容"  >> $descFileif [[ -s $outFmt ]] then  sqno=1  while read -r f1 f2 rest1 rest2  do    if [[ ${#f1} = 0 ]] then       continue    fi    if [[ `expr "$f1" : '#.*'` > 0 ]] then       continue    fi    if (( sqno == 1 )) then      echo "序号 中文名称 英文名称 备注" >> $descFile    fi    echo "$sqno ${f1} ${f2}" >> $descFile    (( sqno = sqno + 1 ))  done < $outFmt  if (( sqno == 1 )) then    echo "N/A"  >> $descFile  fi  echo "" >> $descFileelse  echo "N/A"  >> $descFilefiecho "$descFile created"done

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?