I need to get values from log file, values may be different and need to get it.
example of string:
Tests run: 1042, Failures: 0, Errors: 0, Skipped: 0
i try with:
cat log.log | grep '^Test run:' | sed -e 's/^Test run: //'
but i get: 1042, Failures: 0, Errors: 0, Skipped: 0
i need 4 commands that result was like
first command (tests run)
1042
second command (Failures)
0
third command (Errors)
0
fourth commad (Skipped)
0
You can use the following four commands to obtain the values for Tests run
, Failures
, Errors
, and Skipped
respectively:
cat log.log | sed 's/Tests run: \([0-9]\+\).*/\1/g'
cat log.log | sed 's/.*Failures: \([0-9]\+\).*/\1/g'
cat log.log | sed 's/.*Errors: \([0-9]\+\).*/\1/g'
cat log.log | sed 's/.*Skipped: \([0-9]\+\).*/\1/g'
grep '^Tests run:' <<END | grep -o '[0-9]\+'
Tests run: 1042, Failures: 0, Errors: 0, Skipped: 0
junk
Tests run: 1, Failures: 2, Errors: 3, Skipped: 4
END
outputs
1042
0
0
0
1
2
3
4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With