I sat down yesterday to write this script and have just realised that my methodology is broken........
In essense I have.....
----------------------------------------------------------------- (This line really is in the file)
Service ID: 12345
Event ID: 67890
start_date: 0xdde8 21:00:00 (Sat May 31 22:00:00 2014)
duration: 01:00:00
name: Any old name info could be in here
text: Extended information description......
Content Type: Specific set of 10 different flag types
Event CRID: /XXYYZZ
----------------------------------------------------------------
Service ID: 54321
Event ID: 09876
start_date: 0xdde9 20:00:00 (Sun Jun 1 21:00:00 2014)
duration: 02:00:00
name: Any old name info could be in here
text: Extended information description......
Content Type: Specific set of 10 different flag types
Event CRID: /YYZZXX
---------------------------------------------------------------------------------
Notes....there can be other new fields introduced from the source witout notice and with no control over naming.
And so on repeated up to a couple of thousand times.
What I want to do is the following..
Match against the Service ID variables (specific values, got from different external source) and partial match against the name for specific words.....
So I had coded this as a:-
cat /imputfile.txt | while read LINEVAR ; do
if [[ $LINEVAR == "Service ID:"* ]] && [[ $LINEVAR == *$VARIABLE1* || $LINEVAR == *$VARIABLE2* ]]; then
echo "Found a match........"
do some stuff
done
I've just realised my flawed thinking.......I need the data from the:-
start_date
duration
name
text
event crid
Lines to be able to complete my data process and of course as I'm reading this on a LINE by LINE basis I can't then identify the correct subsequent fields in the source file....basically I'm a twit!!
So I have to come up with a different method but I'm having a brain f*rt and can't think, partly because I don't do a lot of bash so syntax always has to be re-looked up.
Ideas?