I made this batch script that is parsing a file and displaying my values if found :
#!/bin/bash
myFile="my-services.log"
while read p; do
re="(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2},\d{3}).*:(\d*)"
if [[ $p =~ $re ]]; then
echo ${BASH_REMATCH[0]}
echo ${BASH_REMATCH[1]}
echo ${BASH_REMATCH[2]}
fi
done <$myFile
My log file contains things like this
2017-03-24 07:51:43,368 my log id :469565
My script runs well, but doesnt match anything even with data that are matching my regex. I checked my regex with my file editor and it is finding occurrences, so it is strange.
Please note that I was highly insprired from Regular Expression in Bash Script and Multiple matches in a string using regex in bash