来自文件内容的命令行参数 [英] command line arguments from a file content
本文介绍了来自文件内容的命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将文件内容转换为Unix命令的参数?
将参数转换为文件内容如下:
echo ABC> file.txt
但另一个方向?
解决方案
如果你的shell是bash(其他), $(cat afile)
的快捷方式是 $(< afile)
,所以你可以写:
mycommand file.txt)
在命令替换部分中的bash手册页中记录。 p>
另外,让你的命令从stdin读取,因此: mycommand< file.txt
How do I turn file content into an argument for a Unix command?
Turning an argument into file content is done as:
echo ABC > file.txt
But the other direction?
解决方案
If your shell is bash (amongst others), a shortcut for $(cat afile)
is $(< afile)
, so you'd write:
mycommand "$(< file.txt)"
Documented in the bash man page in the 'Command Substitution' section.
Alterately, have your command read from stdin, so: mycommand < file.txt
这篇关于来自文件内容的命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文