使用文件作为bash脚本的输入?

时间:2017-09-15 19:28:29

标签: bash file input readfile

我目前有一个简单的bash脚本,当我使用用户输入时工作正常,但是我想用一个文件作为输入。这是我现在的代码

kubectl describe ingress/<name>

这是我创建的一个小文件,我希望将其用作输入。该文件将在稍后扩展,其中包含更多案例。 input.txt中

#!/bin/bash
go=0
while [ $go ]; do
  echo -e "Enter one of the following actions or press CTRL-D to exit.\n\
  C - create a customer file\n\
  P - accept customer file\n\
  F - find customer by apartment number\n\"
  if ! read option ; then
     break
  fi
  case "$option" in
     C) . ./create.bash
        continue
        ;;
     P) . ./payment.bash
        continue
        ;;
     F) . ./find.bash
        continue
        ;;
     *) echo -e "Error: invalid action value\n"
   esac
done

对于案例C bboard@gmail.com Bill Board APT-09 120 2017-09-08 读取C并且C)使用以下文本,就像它是正常的用户输入一样。我不知道该如何解决这个问题。到目前为止,我已尝试create.bash./menu < input.txt,但这些都无法正常工作。

0 个答案:

没有答案
相关问题