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

发布于 2021-11-26 01:05:24 字数 2578 浏览 942 评论 6

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

怎么把单引号内的内容提取出来,输出到新的文件中呢?因为要用到单引号中的那些软件名。在下不知道怎么用合适的正则表达式

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

毁梦 2021-11-26 21:36:28

楼主你是打算正则匹配列出这些软件名然后重装解决dpkg配置错误么?

温柔少女心 2021-11-26 21:31:28

我是把匹配的那些软件都卸载了,出错原因不一定一样

苍暮颜 2021-11-26 21:26:56

你好,我想问一下我安装软件时也是报这个错,这个问题你是如何解决的?

秉烛思 2021-11-26 21:08:47
vim
进入命令行模式
:r /tmp/aa.txt
:%s/.*'(.*)'.*/1/g
:w software.txt

悲喜皆因你 2021-11-26 20:33:32

多谢多谢!!

把昨日还给我 2021-11-26 19:48:04
[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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文