tail命令在bash脚本中使用时抛出错误

时间:2014-05-13 10:56:43

标签: bash tail

for file in swap_pricer swap_id_marks swaption_id_marks
do

    if [ ! -e $file ] && [ "$context" == "INTRADAY" ]
      then
        cp -f $working_dir/brl/$file $file
      else
        tail -n 7 $working_dir/brl/$file >> $file
      fi

      echo "[`date +'%D %T'`] Removing file ${excel_txt_dir}/$file.txt"
      if [ -e ${excel_txt_dir}/${file}.txt ]
      then
        rm -f ${excel_txt_dir}/${file}.txt
      fi
      cp -f ${file}.txt ${excel_txt_dir}/${file}.txt
      cp -f ${file}.txt ${excel_txt_dir}/${file}_${naming_date}.txt
      cp -f ${file}.txt ${file}_${naming_date}.txt
      cp -f ${file}.txt ${excel_txt_dir}/${file}_${naming_date}_${price_time}.txt

done

上面的代码是bash脚本的一部分......已经从csh脚本中复制了。

我收到错误:

tail: cannot open input

请帮我解决错误。

1 个答案:

答案 0 :(得分:0)

在你的脚本中,tail将+7解释为文件参数并抱怨它无法打开它。

尝试使用tail -n 7代替tail +7