0

i know there are alot of answers out there - but I am yet to find one which answers my question:

Hopefully someone can help!

I have a configuration file which is laid out like so:

define name{ name Stephen URL: www.stephen.com } define name { name Bob URL: } 

What I need to do using grep is to search this file - and if URL is blank then return the name - in the above instance, it would return Bob.

Thanks in advance.

0

1 Answer 1

1
grep -B1 'URL:[ ]*$'|grep -oP '[ ]*name[ ]*\K.*' 
Sign up to request clarification or add additional context in comments.

2 Comments

Hi thanks for answering, can you explain this to me please? '[ ]*name[ ]*\K.*'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.