Ravi kumar
Ravi kumar

Reputation: 129

regex in awk to perform string manipulation

I have a line as below,

`string;{env=>{world=>is,always=>beautiful,gods=>grace}}`

I want to print to do some regex awk to print as below,

`string : env`

I can do it using cut to print "env" but not sure how to do print two strings.

Upvotes: 2

Views: 60

Answers (1)

anubhava
anubhava

Reputation: 785058

You can try this awk:

s='string;{env=>{world=>is,always=>beautiful,gods=>grace}}'
awk -F '[;{}=]+' '{print $1, ":", $2}' <<< "$s"

string : env

Upvotes: 2

Related Questions