Cheezmeister
Cheezmeister

Reputation: 4985

How can I accomplish this `cat` usage more tersely?

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

Upvotes: 1

Views: 118

Answers (2)

glenn jackman
glenn jackman

Reputation: 246807

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

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798676

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

Upvotes: 7

Related Questions