Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 bash shell 脚本中解析一个字符串
'serverDN' :'/DC=ch/DC=cern/OU=computers/CN=myserverName', \
结果应该是这样的
/DC=ch/DC=cern/OU=computers/CN=myserverName
有什么帮助???
echo "'serverDN' :'/DC=ch/DC=cern/OU=computers/CN=myserverName', \\" | awk -F"'" '{print $4}' /DC=ch/DC=cern/OU=computers/CN=myserverName
去掉开头和结尾:
string=${string#*:\'} string=${string%\'*}