不正狼 发表于 2018-8-23 10:22:29

shell小例子

  要求:

[*]  当前若不存在result目录,则创建此目录。
[*]  当前如果存在SoCWatchOutput.csv,则把它移动到result目录下
[*]  接上,传递参数kpi_name,
  #!/bin/sh
  #Used to save CSV file
  #write it by baozhen:2015.12.9
  kpi_name=$1      # $1是紧接着脚本执行后的参数
  myPath="./results"
  myFile="./SoCWatchOutput.csv"
  if [ ! -d "$myPath" ];then    #如果myPath目录不存在
  mkdir ./results
  fi
  if [-f "$myFile" ];then   #如果myFile文件存在
  mv ./SoCWatchOutput.csv./results/SoCWatchOutput_${kpi_name}.csv#字符串相连用${}
  else
  echo "no .csv file"
  fi

页: [1]
查看完整版本: shell小例子