How to parse pipe with multiple commands independently?

Posted by yarun can on Super User See other posts from Super User or by yarun can
Published on 2014-05-29T15:55:32Z Indexed on 2014/08/20 22:24 UTC
Read the original article Hit count: 281

Filed under:
|
|
|

How can I parse output of a single command by multiple commands without truncating at each step?

For example ls -al|grep -i something will pass every line that has "something" in it to the next pipe which is fine, but that also means every other line in the pipe is discarded since there wont be matching the condition. What I want is to be able to operate on single pipe by many commands independently.

In this case it a pipe from Mutt which passes the whole message body. I want to get grep, sed, delete and assign each of these to bash variables maybe.

Initially what I want is to be able to assign "message id" to a variable, "subject" to another variable etc Then pass those into proper commands arguments.

Here is how it will be

MessageBodyFromMutt|grep something -Ax -Bx |grep another thing from the original message| sed some stuff from the original message| cut from here to there

Obviously the above line does not do what I want.

I want all these commands to operate on the original message body. I hope it makes sense

© Super User or respective owner

Related posts about command-line

Related posts about bash