我怎样才能更简洁地完成这个“cat”用法?

发布于 2024-10-02 08:27:51 字数 252 浏览 1 评论 0原文

针对真实用例的开放式问题(要有创意!)。本质上,我想 cat (1) 现有文件 (2) 程序的输出和 (3) 特定的文本位。在管道、回显和重定向之间,我觉得我应该能够做得比这更好!

pandoc -t latex -o mydoc.tex mydoc.rst
echo \\end{document} > footer.tex
cat header.tex mydoc.tex footer.tex > fulldoc.tex

Open ended question (be creative!) for a real use case. Essentially I want to cat (1) an existing file (2) the output of a program and (3) a specific bit of text. Between pipes, echo and redirects, I feel like I should be able to do better than this!

pandoc -t latex -o mydoc.tex mydoc.rst
echo \\end{document} > footer.tex
cat header.tex mydoc.tex footer.tex > fulldoc.tex

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

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

发布评论

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

评论(2

野鹿林 2024-10-09 08:27:51
{
  cat header.tex
  pandoc -t latex mydoc.rst
  echo \\end{document}
} > fulldoc.tex
{
  cat header.tex
  pandoc -t latex mydoc.rst
  echo \\end{document}
} > fulldoc.tex
挽你眉间 2024-10-09 08:27:51

如果您使用的是 bash,则可以使用进程替换和此处的字符串:

cat header.tex <(pandoc -t latex mydoc.rst) <<<'\end{document}' > fulldoc.tex

If you're using bash, you can use process substitution and a here string:

cat header.tex <(pandoc -t latex mydoc.rst) <<<'\end{document}' > fulldoc.tex
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文