I want to grep for some specific lines from a log file, and then capture a specific part of that output in a variable and use it in other commands.
The grep command I have is the following, where $1 is a date:
grep -a --binary-file=text "pattern" /home/path/archive/logs/path.log-$1
Example output:
/home/path/archive/logs/path.log-2015-04-13.0.gz:2015-05-13 00:43:49,779 INFO [DEUX-DR-SAMPLE-1] c.i.s.p.DeuxProxyPMMProcessor [DEUX : 361] SVRREQ|dataID|server request: (deliver: (pdu: 0 5 0 282190) (addr: 1 1 adress) (addr: 1 1 mssidn) (sm: enc: ASCII msg: id:dataID stat:pattern)
From this output I want to take only the dataID
field and save it in a variable for use in other commands. There are hundreds of lines like this though, and the number of spaces can't be used as a delimiter to get the dataID
field because it varies from line to line.