sed 's/$//g' a.txt
把最后一个数字替换为空。
sed 's/\(*\)$/\1/g' a.txt
分组,前面几个数字为一组,后面最后一个数字为第二组,然后用第一组来替换整个字符串。
peter@ubuntu-maverick:~/temp$ cat a.txt
12345678910
58156451511
62264545655
23331561615
21215121525
peter@ubuntu-maverick:~/temp$ sed 's/\(*\)$/\1/g' a.txt
1234567891
5815645151
6226454565
2333156161
2121512152
Last edited by peterhuang on 2010-12-2 at 21:42 ]