How to concatenate stdin and a string?

前端 未结 9 1476
死守一世寂寞
死守一世寂寞 2021-01-30 01:49

How to I concatenate stdin to a string, like this?

echo \"input\" | COMMAND \"string\"

and get

inputstring
9条回答
  •  余生分开走
    2021-01-30 02:48

    use cat - to read from stdin, and put it in $() to throw away the trailing newline

    echo input | COMMAND "$(cat -)string"
    

    However why don't you drop the pipe and grab the output of the left side in a command substitution:

    COMMAND "$(echo input)string"
    

提交回复
热议问题