I have a log file that display the serial output coming from different places. Sometime the string in search gets clobbered with the other strings and consequently change form. For example:
In this case I want to check for "complete" string but since it is clobbered with the network stuff, i cant verify its existence. Is there a way I can use some sort of string matching to detect such strings?
sets the variable final to plete
(assuming your file ends at the complete message??)
cat complete.txt | grep -B 1 $final | head -1
gives the preceeding line (although lots of other ways)
now you are left with how to figure out if complete is spelled on those two.
thought about using
tr -cd [complet]
to get rid of everything but those characters
but am now thinking to count the number of characters on last line (final variable) and subtract from the 8 in complete. and then check to see if that number of characters is how the previous line begins.
"Complete" can be anywhere in the file not necessarily at the end of the file... This approach might work but not sure how to implement it: accepting arbitrarily many characters between each char in the pattern c*o*m*p*l*e*t*e