+ -
当前位置:首页 → 问答吧 → 100分请教高手sed 表达式

100分请教高手sed 表达式

时间:2011-06-17

来源:互联网

http://www.cublog.cn/u/21948/showart_413005.html

C/C++ code
 

[armlinux@lqm bash]$ cat test1
uid=500(guest) gid=500(others) groups=500(users),11(floppy)
 
    下面把小括号内的值单独取出,如果利用贪婪规则,解决方案如下:
 

1 sed -e 's/[^(]*(\([^)]*\).*/\1/' test1
2 sed -e 's/[^(]*(\([^)]*\)[^(]*(\([^)]*\).*/\2/' test1
3 sed -e 's/[^(]*(\([^)]*\)[^(]*(\([^)]*\)[^(]*(\([^)]*\).*/\3/' test1
4 sed -e 's/.*(\(.*\))/\1/' test1



1 sed -e 's/[^(]*(\([^)]*\).*/\1/' test1
这一句中的[^(]是什么意思?
整句怎么分析?

作者: ZhengKarl   发布时间: 2011-06-17

太复杂了,帮你顶

作者: windman521   发布时间: 2011-06-17