如何仅获取yum更新列表 [英] How to get just a list of yum updates

查看:93
本文介绍了如何仅获取yum更新列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我一直都有这个问题.我只想使用yum从Linux系统(RHEL或Fedora)通过bash脚本在文件中列出可用的更新,但我始终必须处理创建的Header信息,如下所示:

OK I have always had this problem. I want JUST the available updates listed in a file via bash script from a Linux system (RHEL or Fedora) using yum but I always have to deal with the Header information created which looks like this:

    Loaded plugins: XXXX-repo  XXXX-updates
                  : WWWWWW-repo  something-updates  QQQQQ-updates
     Updated packages
     package1.i686         1:234                  RHEL 6.5 updates
     package2.i686         1:234                  RHEL 6.5 updates
     package3.i686         1-234                  RHEL 6.5 updates
     package4.noarch       1.234                  RHEL 6.5 updates

我想要的只是package1,package2等的列表,这似乎很简单,但这不是因为我不能仅对"updates"或:"进行grep.我看错了吗?为什么我不想捕获在脚本中找到的更新?我应该只更新并检查已更新的内容吗?有想法吗?

All I want is a list of package1,package2, etc. which seems simple enough but it isn't because I can't just grep on "updates" or ":". Am I looking at this wrongly? Why would I not want to capture what updates were found in a script? Should I just update and check what has been updated instead? Thoughts?

PS>我不能使用--noplugins选项.

PS> I can not use --noplugins option.

到目前为止,我已经提出了这个建议,

So far I have come up with this,

     sudo yum check-update | grep "\." | awk '(NR >=1) {print $1;}' | grep '^[[:alpha:]]'

基本上抓住其中带有句点的行,即第一行,并确保它首先包含字母.也许已经完成了,但似乎行得通.

Basically grab the lines with a period in them, the first line, and make sure it first contains alpha letters. Perhaps over done but it seems to work.

推荐答案

仅打印(但不包括)更新的软件包"之后的行

To only print lines following (but not including) "Updated packages"

yum check-update | awk 'p; /Updated packages/ {p=1}'

注意,在我的Fedora系统上,空白行将"header"与可更新软件包列表分开,因此我将使用 awk'p;/^ $/{p = 1}'

Note, on my Fedora system, a blank line separates the "header" from the list of updatable packages, so I would use awk 'p;/^$/{p=1}'

这篇关于如何仅获取yum更新列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆