joe*_*hau 6 regex bash awk sed
在字符串中,我试图用下划线替换括号之间的所有空格.例如,鉴于this ( is my ) simple example我想得到this (_is_my_) simple example.
this ( is my ) simple example
this (_is_my_) simple example
我正在研究bash,并考虑为sed创建一个替换表达式,但是我无法想出一个简单的单行解决方案.
期待您的帮助
per*_*eal 6
使用sed:
sed ':l s/\(([^ )]*\)[ ]/\1_/;tl' input
如果你有不平衡的括号:
sed ':l s/\(([^ )]*\)[ ]\([^)]*)\)/\1_\2/;tl' input
归档时间:
13 年,1 月 前
查看次数:
1297 次
最近记录: