linux中提取文本中指定的字符串

好铁 发布于 2013/09/08 16:21
阅读 7K+
收藏 2

linux下,有如下文件内容:


dpkg:警告:files list file for package 'libclutter-1.0-0:i386' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libtext-wrapi18n-perl' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'slurm' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libfftw3-3:i386' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libbindex-java' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libnotify-bin' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'python-urllib3' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libbonoboui2-0:i386' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'mysql-client-core-5.5' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libslf4j-java' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libaspectj-java' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'deja-dup-backend-gvfs' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'tcpd' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libavutil-extra-51:i386' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'python-pkg-resources' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libgtkspell0' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libafpclient0:i386' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'ubuntu-release-upgrader-gtk' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libdb-je-java' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'libexempi3:i386' missing; assuming package has no files currently installed
dpkg:警告:files list file for package 'xserver-xorg-input-vmmouse' missing; assuming package has no files currently installed

怎么把单引号内的内容提取出来,输出到新的文件中呢?因为要用到单引号中的那些软件名。在下不知道怎么用合适的正则表达式
加载中
0
樊睿
樊睿
[root@web2 ~]# awk -F "'" '{print $2}' /tmp/aa.txt  > software.txt
[root@web2 ~]# cat software.txt 
libclutter-1.0-0:i386
libtext-wrapi18n-perl
slurm
libfftw3-3:i386
libbindex-java
libnotify-bin
python-urllib3
libbonoboui2-0:i386
mysql-client-core-5.5

好铁
好铁
多谢多谢!!
1
kason_過客
kason_過客

vim
进入命令行模式
:r /tmp/aa.txt
:%s/.*'\(.*\)'.*/\1/g
:w software.txt

0
kason_過客
kason_過客
你好,我想问一下我安装软件时也是报这个错,这个问题你是如何解决的?
0
好铁
好铁
我是把匹配的那些软件都卸载了,出错原因不一定一样
0
coat
coat
楼主你是打算正则匹配列出这些软件名然后重装解决dpkg配置错误么?
返回顶部
顶部