Reputation: 1413
Example log : "some data7.575=tf.some data2.0=tf.some data1.23=tf.some data.."
I want to get each TF value as output.
i.e. output should be
TF=7.575
TF=2.0
TF=1.23
How can I parse this? Using Shell script (preferrable). Unix command or using Java.
Upvotes: 2
Views: 477
Reputation: 785186
You can use this grep -P
command:
grep -oP '[\d.]+(?==tf\.some)' file
7.575
2.0
1.23
Or using this awk:
awk -F 'data|=' '{for(i=2; i<=NF; i+=2) print "TF=" $i}' file
TF=7.575
TF=2.0
TF=1.23
Upvotes: 2