巴什 - 如何将参数传递到通过标准输入读剧本 [英] Bash - How to pass arguments to a script that is read via standard input
本文介绍了巴什 - 如何将参数传递到通过标准输入读剧本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图从标准输入执行脚本,并传递参数给它。有没有办法做到这一点?
让我们说,我有以下几点:
猫script.sh |庆典
我将如何传递参数给脚本?
我不希望做到这一点:
的bash script.sh参数
这也不:
./ script.sh参数
解决方案
在Linux上,
猫script.sh |庆典的/ dev /标准输入参数
似乎工作。
I am trying execute a script from standard input and also pass arguments to it. Is there a way to do it?
Let's say that I have the following:
cat script.sh | bash
How would I pass the arguments to the script?
I do not want to do this:
bash script.sh arguments
Nor this:
./script.sh arguments
解决方案
On Linux,
cat script.sh | bash /dev/stdin arguments
seems to work.
这篇关于巴什 - 如何将参数传递到通过标准输入读剧本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文