- 论坛徽章:
- 145
|
回复 1# psmzs
$ echo "abcaefg" | sed 's/a(bc)a/\1/'
sed: -e expression #1, char 12: invalid reference \1 on `s' command's RHS
$ echo "abcaefg" | sed -r 's/a(bc)a/\1/'
bcefg
$ echo "abcaefg" | awk '{gsub(/a(bc)a/,"\1")}1'
efg
$ echo "abcaefg" | awk '{gsub(/a(bc)a/,"\1")}1' | hexdump -C
00000000 01 65 66 67 0a |.efg.|
00000005
$ echo "abcaefg" | awk '{$0=gensub(/a(bc)a/,"\1","")}1' | hexdump -C
00000000 01 65 66 67 0a |.efg.|
00000005
$ echo "abcaefg" | awk '{$0=gensub(/a(bc)a/,"\\1","")}1'
bcefg
$ echo "abcaefg" | perl -pe 's/a(bc)a/\1/'
bcefg
|
|