Reputation: 24795
I want to run a program which writes some outputs to a file. Now in this file, I will grep for certain strings and write them to another file. I don't want to serialize the process. Instead I want to pipe the commands. However this command doesn't work
./run_prog | grep READ > read_data.txt
Upvotes: 0
Views: 157
Reputation: 11466
As already mentioned, sounds like your program might be writing to STDERR instead of STDOUT. To make sure you capture that as well, try this:
./run_prog 2>&1 | grep READ > read_data.txt
Upvotes: 1
Reputation: 8423
Make sure your ./run_prog
gives your output to STDOUT. The following example shows that it should work.
$>echo "READ" | grep READ > read_data.txt
$>cat read_data.txt
READ
$>
Since you are now assured it should work debug by just running ./run_prog
then add | grep
.
Upvotes: 1