I've got a long running process that I'd like to capture parts of its output to various files as it happens.
I thought I could write something to:
- output to stdout as it happens
- capture all output in file
/tmp/
- write all lines that match
3
to file/tmp/2
$ output_data_constantly | tee /tmp/1 | grep 3 > /tmp/2
but it doesn't seem to work - nothing is output to stdout
Any suggestions?
output_data_constantly
:
#!/usr/bin/env bash
for i in {1..10000}; do
echo $i ;
sleep 0.25;
done
Note that I'm on a mac, and my Bash version is:
$ bash --version 11:53:30
GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin17.3.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.