假设我想运行 ./program
带有字符串参数
而不是打字
./program string
每次,我该怎么做./program <file>
在哪里 <file>
是包含字符串的文件吗?
谢谢你
最佳答案
这应该可以解决问题:
./program `cat file`
如果你想在一个参数中包含整个文件内容,请添加双引号(在 bash 中测试过。我认为它可能因 shell 而异):
./program "`cat file`"
关于linux - 使用 linux 如何将文件的内容作为参数传递给可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4241369/