How can I append text in the middle of a pipeline?

1

1

With cat its possible to append a file to the data passing through a pipeline:

foo | cat - somefile.txt | bar

Is there a command that lets me append text without using an intermediate file?

foo | xxx - "contents of somefile" | bar

hugomg

Posted 2015-04-24T01:27:45.867

Reputation: 479

Answers

1

You could try:

{ foo; echo contents not stored in file; } | bar

or (almost the same, but starts a subshell):

( foo; echo contents not stored in file ) | bar

Edit: A totally different approach, closer in design to what you were looking for:

foo | cat - <(echo additional contents) | bar

See "Process substitution" in bash's manual.

egmont

Posted 2015-04-24T01:27:45.867

Reputation: 1 791