简体   繁体   English

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

[英]Executing two commands together in command line

I followed previous threads: 我遵循之前的主题:

I want to execute shell file and write into text parallel. 我想执行外壳文件并并行写入文本。 Content should be written first in text file and the shell file should be executed. 内容应首先写入文本文件,然后执行外壳文件。

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

Another try: 另一种尝试:

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

What is the correct way? 正确的方法是什么?

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

I think you mean this - you want a script to create a script and then run it: 我认为您的意思是-您想要一个脚本来创建一个脚本然后运行它:

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

为什么不跟随?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM