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=

1 Answer 1

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 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.