希望有人能帮助我使用sed / awk管道,我可以在bash中使用它来获取这样的输入列表。
Battleztar Bazinga
com.plumanalytics
ECCP/1.0
Go!Zilla
GT::WWW
MegaIndex.ru
MS Web Services Client
POE-Component-Client-HTTP然后给出这样的输出列表
Battleztar\ Bazinga
com\.plumanalytics
ECCP\/1\.0
Go\!Zilla
GT\:\:WWW
MegaIndex\.ru
MS\ Web\ Services\ Client
POE\-Component\-Client\-HTTP基本上用反斜杠\转义所有特殊字符和空格
发布于 2017-10-15 10:17:23
您可以使用这个sed
sed 's/[^[:alnum:]_]/\\&/g' file
Battleztar\ Bazinga
com\.plumanalytics
ECCP\/1\.0
Go\!Zilla
GT\:\:WWW
MegaIndex\.ru
MS\ Web\ Services\ Client
POE\-Component\-Client\-HTTP[^[:alnum:]_]将匹配任何字符不是阿尔法数字和下划线.\\&将在匹配的文本之前放置\。https://stackoverflow.com/questions/46753932
复制相似问题