I need to discovery patterns in a string by bash, I would like put auto-execution with crontab.
I have a string that contain data like
%d/%m/%Y %H:%i aaa bbb ccc 123456 ddd 7890 eee
and something like that. It's a report.
I thought to define constants like string masks, and compare every substring with my masks. I think I will use a mix with lenght and char positition.
I'm googling to have better idea and watch some other implementation, but I'm not finding useful results.
Any suggestion? Thanks.
Edit: some sample of input
01/01/2015 06:20 EXAMPLE 2 (001) Foo bar X(12)
02/01/2015 12:03 EXAMPLE 1 (000) 01234567 Baz bax X(04)
03/01/2015 10:37 EXAMPLE 1 (000) Bam bac (X:1-16). [ SOMEGUY ]
04/01/2015 11:04 EXAMPLE 2 (001) 12345678 Baz bax X(12) SOMEACTION
05/01/2015 12:34 EXAMPLE 2 (001) 45678901 Bim bum X(01) SOMEACTION NAME SURNAME
08/08/2015 19:00 SOMEGUY Bic bac. [ SOMEGUY ]
01/01/2015 11:34 EXAMPLE 2 (001) 78901234 Gic gia gim X(01)
whereas as output I need
variabile $date $time $example $codeline $action $message $name $surname
Edit2: I forgot to say I'm looping that lines with this
while IFS=' ' read -ra field; do
...
done <<< "$line"