Netcat server output with multiple greps
- by Sridhar-Sarnobat
I'm trying to send some data from my web browser to a txt file on another computer.
This works fine:
echo 'Done' | nc -l -k -p 8080 | grep "GET" >> request_data.txt
Now I want to do some further processing before writing the http request data to my txt file (involving regex maniuplation). But if I try to do something like this nothing is written to the file:
echo 'Done' | nc -l -k -p 8080 | grep "GET" | grep "HTTP" >> request_data.txt
(for simplicity of explanation I've used another grep instead of say awk)
Why does the 2nd grep not get any data from the output of the first grep? I'm guessing piping with netcat works differently to what I've assumed to get this far. How do I perform a 2nd grep before writing to my txt file?
My debugging so far suggests:
It is nothing to do with stderr vs stdout
Parentheses don't help