SOBIA SHIEKH
SOBIA SHIEKH

Reputation: 1

String Parsing Required

I want to parse a string in bash shell scripting

'serverDN'       :'/DC=ch/DC=cern/OU=computers/CN=myserverName', \

and result should be like this

/DC=ch/DC=cern/OU=computers/CN=myserverName

Any help???

Upvotes: 0

Views: 86

Answers (2)

Dennis Williamson
Dennis Williamson

Reputation: 360105

Strip off the beginning and the end:

string=${string#*:\'}
string=${string%\'*}

Upvotes: 3

Vijay
Vijay

Reputation: 67221

echo "'serverDN' :'/DC=ch/DC=cern/OU=computers/CN=myserverName', \\" |
  awk -F"'" '{print $4}'
/DC=ch/DC=cern/OU=computers/CN=myserverName

Upvotes: 3

Related Questions