Error line number

Hi

I have a error message like this.

ERROR at line 1:
ERROR at line 15:
ERROR at line 49:

I want to grep the number from the ERROR line.

Can some one help here.

Thanks,
Rami Reddy.

use "cut" command
1 Like
awk -F'[ :]' { print $(NF-1) } ' file
1 Like
 
grep -o [0-9]* file
1 Like
awk -F' |:' '{print $4}' file
1 Like

Hi, I add a clarification: if you apply this solution to the error output of a script may be necessary to redirect execute a redirect

./script.sh 2>&1 | awk -F' |:' '{print $4}'
1 Like