I have a hacky thing that I'd like to do via the command line because I'd rather not write a program to do it. For some background, the sensor is just sending UDP packets that are simply caught with netcat, nc -ul 192.168.1.1 10000 > output.dat
. In this stream, there's occasionally an error. I have a binary data stream from a sensor that will occasionally send an error message as "$ERROR<binary for 129 bytes>".
I would like to come up with some way to parse this error message so that I can just pipe the matches to a file. I believe that the proper regex would be (\$ERROR).{129}
, but I've had no luck actually implementing it. I've been simulating the data stream by doing cat file.bin | grep -aEi '(\$ERROR).{129}'
but it's not working as I'm getting more characters than the error message.
I'm hoping to use this to watch a stream for the error message and redirect it to a file. Any suggestions on how to fix this regex would be greatly appreciated.