One output into multiple different files

Hello,

How can I redirect the output from an application into multiple different files, depending on the contents? Something like multiple greps putted into if-then-else clause... but all of this in close to real-time (not afterwards) .

Thank you very much,

You can do something like this with awk:

your_application |
awk '
/pattern1/{print > "file_with_pattern1"}
/pattern2/{print > "file_with_pattern2"}
' > file_with_other_lines
1 Like