
CODE: [Copy to clipboard]把最后一个数字替换为空。sed 's/[0-9]$//g' a.txt
CODE: [Copy to clipboard]分组,前面几个数字为一组,后面最后一个数字为第二组,然后用第一组来替换整个字符串。sed 's/\([0-9]*\)[0-9]$/\1/g' a.txt
CODE: [Copy to clipboard][ Last edited by peterhuang on 2010-12-2 at 21:42 ]peter@ubuntu-maverick:~/temp$ cat a.txt
12345678910
58156451511
62264545655
23331561615
21215121525
peter@ubuntu-maverick:~/temp$ sed 's/\([0-9]*\)[0-9]$/\1/g' a.txt
1234567891
5815645151
6226454565
2333156161
2121512152
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |