当前位置: 技术问答>linux和unix
这个正则表达该怎么写(shell)
来源: 互联网 发布时间:2017-03-03
本文导语: -rwxr-xr-x 1 root root 30520637 Wed Jul 11 16:20:32 2012 MANU_2012-07-11_16-18-24[0].Mp4* -rwxr-xr-x 1 root root 13359690 Wed Jul 11 16:21:36 2012 MANU_2012-07-11_16-20-42[0].Mp4* -rwxr-xr-x 1 root ro...
-rwxr-xr-x 1 root root 30520637 Wed Jul 11 16:20:32 2012 MANU_2012-07-11_16-18-24[0].Mp4*
-rwxr-xr-x 1 root root 13359690 Wed Jul 11 16:21:36 2012 MANU_2012-07-11_16-20-42[0].Mp4*
-rwxr-xr-x 1 root root 138668923 Wed Jul 11 16:37:48 2012 MANU_2012-07-11_16-27-50[0].Mp4*
-rwxr-xr-x 1 root root 47028033 Wed Jul 11 16:41:14 2012 MANU_2012-07-11_16-37-49[0].Mp4*
向通过过滤把字符行变成:
Jul 11 16:20:32 2012 MANU_2012-07-11_16-18-24[0].Mp4
Jul 11 16:21:36 2012 MANU_2012-07-11_16-20-42[0].Mp4
那位大侠指点一下,谢谢。
-rwxr-xr-x 1 root root 13359690 Wed Jul 11 16:21:36 2012 MANU_2012-07-11_16-20-42[0].Mp4*
-rwxr-xr-x 1 root root 138668923 Wed Jul 11 16:37:48 2012 MANU_2012-07-11_16-27-50[0].Mp4*
-rwxr-xr-x 1 root root 47028033 Wed Jul 11 16:41:14 2012 MANU_2012-07-11_16-37-49[0].Mp4*
向通过过滤把字符行变成:
Jul 11 16:20:32 2012 MANU_2012-07-11_16-18-24[0].Mp4
Jul 11 16:21:36 2012 MANU_2012-07-11_16-20-42[0].Mp4
那位大侠指点一下,谢谢。
|
写不写入文件有区别吗?要写入文件就加一个文件重定向嘛:
[nicenight@CSDN ~]$ cat lll.txt
-rwxr-xr-x 1 root root 30520637 Wed Jul 11 16:20:32 2012 MANU_2012-07-11_16-18-24[0].Mp4*
-rwxr-xr-x 1 root root 13359690 Wed Jul 11 16:21:36 2012 MANU_2012-07-11_16-20-42[0].Mp4*
-rwxr-xr-x 1 root root 138668923 Wed Jul 11 16:37:48 2012 MANU_2012-07-11_16-27-50[0].Mp4*
-rwxr-xr-x 1 root root 47028033 Wed Jul 11 16:41:14 2012 MANU_2012-07-11_16-37-49[0].Mp4*
[nicenight@CSDN ~]$ cat lll.txt | tr -d '*' | cut -d' ' -f7-
Jul 11 16:20:32 2012 MANU_2012-07-11_16-18-24[0].Mp4
Jul 11 16:21:36 2012 MANU_2012-07-11_16-20-42[0].Mp4
Jul 11 16:37:48 2012 MANU_2012-07-11_16-27-50[0].Mp4
Jul 11 16:41:14 2012 MANU_2012-07-11_16-37-49[0].Mp4
|
论坛不稳定啊,一下就弄了三个回复,来个正则的,等一晚上没人回复,那就弄个小号来回复了:
[nicenight@CSDN ~]$ cat lll.txt | sed -r 's/(.*Wed |*)//g'
Jul 11 16:20:32 2012 MANU_2012-07-11_16-18-24[0].Mp4
Jul 11 16:21:36 2012 MANU_2012-07-11_16-20-42[0].Mp4
Jul 11 16:37:48 2012 MANU_2012-07-11_16-27-50[0].Mp4
Jul 11 16:41:14 2012 MANU_2012-07-11_16-37-49[0].Mp4