在命令行中一起执行两个命令

时间:2014-09-18 12:13:53

标签: linux shell command-line

我遵循了之前的主题:

我想执行shell文件并并行写入文本。应首先在文本文件中写入内容,然后执行shell文件。

# input.txt < "I love cat, she is nice" && ./test.sh
bash: I love cat, she is nice: No such file or directory

另一次尝试:

# ./test.sh && input.txt < "I love cat, she is nice"
batch processes ..
bash: I love cat, she is nice: No such file or directory

正确的方法是什么?

3 个答案:

答案 0 :(得分:2)

echo "I love cat, she is nice" > input.txt && ./test.sh

答案 1 :(得分:0)

我认为你的意思是这个 - 你想要一个脚本来创建一个脚本然后运行它:

echo "echo hello" > go.sh && chmod +x go.sh && ./go.sh
hello

答案 2 :(得分:0)

为什么不跟随?

echo "I love cat, she is nice" > input.txt; ./test.sh
相关问题