linux - 使用 linux 如何将文件的内容作为参数传递给可执行文件?

标签 linux

假设我想运行 ./program带有字符串参数

而不是打字 ./program string每次,我该怎么做./program <file>在哪里 <file>是包含字符串的文件吗?

谢谢你

最佳答案

这应该可以解决问题:

./program `cat file`

如果你想在一个参数中包含整个文件内容,请添加双引号(在 bash 中测试过。我认为它可能因 shell 而异):

./program "`cat file`" 

关于linux - 使用 linux 如何将文件的内容作为参数传递给可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4241369/

相关文章:

linux - 如何恢复已删除的 crontab(-r 选项)

linux - 源代码在 shell 脚本中不起作用

linux - Beaglebone devm_pwm_get 返回 ENODEV

c - 在 Linux 内核中启用调度程序统计信息

regex - 如何使用正则表达式在 Unix 中搜索文件?

php - UTF-8贯穿始终

linux - 即使在 "close"操作成功后,NFS 软挂载是否会导致静默损坏

linux - 如何对收到的邮件执行 PHP 脚本?

c++ - 跨平台 C++ : Use the native string encoding or standardise across platforms?

linux - 生成内核镜像时,出现无法识别的命令行选项 ‘-mlongcalls' 错误