Amrith
Amrith

Reputation: 57

Remove extra quotation marks in the grep output

TUNNEL_TCP=$(grep -Po 'http:\/\/([\S]*?)"' ./tunnel_info.json )

the above cammand is used to get an http link example: www.224.ngrok.io but the output is say www.224.ngrok.io"

How can I remove the extra " at the end?

I tried editing the " from the grep command but it doesn't work.

Upvotes: 2

Views: 233

Answers (1)

Maroun
Maroun

Reputation: 95998

You can use positive lookahead:

grep -Po 'http:\/\/([\S]*?)(?=")'

(?=")matches the " without making it part of the match.

Upvotes: 1

Related Questions