我有如下输入文件,我希望在输出中替换set xx { \
&之间的字符串}
。如何在csh中编码?
输入:
set a 1
set b 2
set xx { \
a/c/d \
apple/d/e/g \
guava/s/s/g/b/c \
}
set c 3
输出:
set a 1
set b 2
set xx { \
a/*c*/d* \
apple/d/*e*/g* \
guava/s/s/g/*b*/c* \
}
set c 3
$ cat fixer.sed
#!/bin/sed -f
/set xx {/ , /}/ {
s@\(/.*\)\([^/]\)\(/[^/]*\)\( *[\]\)$@\1*\2*\3*\4@
}
/set xx {/ , /}/
是一个范围表达式,sed
扫描每一行,但只s@...@...@
在提供的范围之间的行上执行操作。
$ chmod +x fixer.sed # only the first time you create file
输出
$ ./fixer.sed txt.txt
set a 1
set b 2
set xx { \
a/*c*/d* \
apple/d/*e*/g* \
guava/s/s/g/*b*/c* \
}
set c 3
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句