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"
grep. Otherwise you need to improve your question with 3 lines of sample input (including one line that should NOT be processed), AND your required output from the sample input. You should read enough about grep (many tutorials available) that you can improve your question with an attempt with a reg-exp to match the lines yous want to capture. Otherwise you're likely to get downvoted and close votes. Good luck.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) SOMEACTION05/01/2015 12:34 EXAMPLE 2 (001) 45678901 Bim bum X(01) SOMEACTION NAME SURNAME08/08/2015 19:00 SOMEGUY Bic bac. [ SOMEGUY ]01/01/2015 11:34 EXAMPLE 2 (001) 78901234 Gic gia gim X(01)well, this are examples coming from my real world{}tool at the top left of the edit box after highlighting your text with line breaks. Good luck.$date $timeis easy, what about$name $surname $action. It seems like your data is a jumble of incomplete information. You'll need to show that you've tried to solve at least some of this on your own. Have you worked thru anawktutorial or two? It could be very helpful. see grymoire.com/Unix/Awk.html ? Good luck.