【发布时间】:2019-12-23 16:51:52
【问题描述】:
我是 bash 新手,我无法使用 bash 在终端上 cat 文件和使用管道命令。
这是我在终端命令行上尝试过的
$ cat data | readlooptest
但是,当我使用管道时,我总是会收到此消息 |
-bash: readlooptest: command not found
我有一个名为 readlooptest 的脚本和一个数据文件
readlooptest 的脚本内容
#!/bin/bash
read myLine
sum=0
for i in $myLine
do
sum=`expr $sum + $i`
done
echo "sum is: $sum"
数据文件内容为
6 4 4 7 7
所以一旦在终端输入命令,输出应该是
$ chmod +x readlooptest
$ cat data | readlooptest
sum is : 28
但是我得到了
-bash: readlooptest: command not found
【问题讨论】:
标签: bash macos unix command-line terminal