0

So, here's the thing. I have a file contains like this:

LOG=123 HEY=BRO FOO=BAR LOG=124

I need the value of LOG= and an output like this:

123
124

I already tried using this command:

echo "$LOG" | egrep -o 'LOG=.*'

but it only outputs everything after the first word and not the values of all words with LOG=

Azikun
  • 3
  • 1

1 Answers1

0

If you're looking only for the numeric values, you can use below command

grep -oE 'LOG=([0-9]+)' log | cut -d= -f2

If the value can be alphanumeric, use below command

grep -oE 'LOG=([A-Za-z0-9]+)' log | cut -d= -f2