Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate stdin to stdout

Tags:

I am looking for a bash one-liner that duplicates stdin to stdout without interleaving. The only solution I have found so far is to use tee, but that does produced interleaved output. What do I mean by this:

If e.g. a file f reads

a
b

I would like to execute

cat f | HERE_BE_COMMAND

to obtain

a
b
a
b

If I use tee - as the command, the output typically looks something like

a
a
b
b

Any suggestions for a clean solution?

Clarification

The cat f command is just an example of where the input can come from. In reality, it is a command that can (should) only be executed once. I also want to refrain from using temporary files, as the processed data is sort of sensitive and temporary files are always error-prone when the executed command gets interrupted. Furthermore, I am not interested in a solution that involves additional scripts (as stated above, it should be a one-liner) or preparatory commands that need to be executed prior to the actual duplication command.