I want to find a specific line in a log file that contains a string and then writes that line to an array. I'm brand new to this scripting language so I having a difficult time finding the exact answer I need. Here is what I have so far. It's the next step I can't find. Writing the array.
tail -f foo.log | grep --line-buffered "foo"
So say the file contains the following lines:
1516049080,1,item0,0,end
1516049080,item1,item2,0,id,foo:12345678
1516049080,item3,item4,0,files-count,0
I want to find the value foo:12345678 and save that to a variable. The value 12345678 was generated in the log file and at the time of retrieval is not known. The id would, however, always be prefixed by foo:.
Thanks in advance.
Rhonda