通过管道传输

发布于 2024-09-03 21:39:19 字数 172 浏览 3 评论 0原文

我需要通过管道传输数据,并使用这些数据传输文件,我可以在脚本中执行类似的操作吗?

cat ${1} | ./helper ${1}

如果我写有什么区别

cat ${1} | ./helper < ${1}

I need to transfer data via pipe and also transfer file with this data, can I do something like this inside the script?

cat ${1} | ./helper ${1}

and what is the difference if I write

cat ${1} | ./helper < ${1}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无尽的现实 2024-09-10 21:39:19

“<”将文件内容添加到脚本 stdin

管道还会重定向 ./helper 脚本的 stdin 输出,

您可以执行 cat ${1} | ./helper
./helper < ${1} 假设 ${1} 是一个文件名,并在帮助程序脚本中从 /dev/stdin 访问它

"<" adds the file content to your scripts stdin

pipe also redirects the output for stdin of the ./helper script

you could eithe do cat ${1} | ./helper
or ./helper < ${1} assuming ${1} is a filename and in helper script access it from /dev/stdin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文