I have a Java application using a SSH connection, remotely running CLI commands. For a specific command, I would like to pipe the command's output through two regular expressions, finding two correlated subsets of the overall output and return that output back to my program.
For each of the two regular expressions: <RE1> & <RE2>, I would like to format the resulting outputs: <RE1out> & <RE2out> via <action1> & <action2> respectively; then return the final result, for example (please excuse the pseudo shell-script):
<command> | grep -e <RE1> -e <RE2> | (<REout1> given to <action1> and <REout2> given to <action2>) yields <final_output>
Try this
<command> | tee >(grep -e <RE1> | <action1>) >(grep -e <RE2> | <action2>)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With