列出 openSUSE 中的可用补丁会产生以下输出。
导致以下详细信息的命令是zypper patches
. 运行命令时也显示相同的结果zypper list-patches -a
Loading repository data...
Reading installed packages...
Repository | Name | Category | Severity | Interactive | Status | Summary
----------------------------------+--------------------+-------------+-----------+-------------+------------+---------------------------------------------------------------------------------------------------
openSUSE-Leap-15.0-Update | openSUSE-2018-1000 | recommended | moderate | --- | not needed | Recommended update for gnuhealth, proteus, tryton, trytond, trytond_purchase, trytond_stock_supply
openSUSE-Leap-15.0-Update | openSUSE-2018-1004 | security | low | --- | not needed | Security update for ffmpeg-4
openSUSE-Leap-15.0-Update | openSUSE-2018-1005 | security | moderate | --- | not needed | Security update for chromium
openSUSE-Leap-15.0-Update | openSUSE-2018-1006 | security | moderate | --- | applied | Security update for okular
openSUSE-Leap-15.0-Update | openSUSE-2018-1007 | recommended | moderate | --- | applied | Recommended update for tigervnc
例如,在尝试使用命令对“状态”进行排序时,会sort -k 6,6 listing.txt | less
产生以下输出。
----------------------------------+--------------------+-------------+-----------+-------------+------------+---------------------------------------------------------------------------------------------------
Loading repository data...
Reading installed packages...
openSUSE-Leap-15.0-Update-Non-Oss | openSUSE-2018-1082 | recommended | moderate | --- | not needed | Security update for opera
openSUSE-Leap-15.0-Update-Non-Oss | openSUSE-2018-1240 | recommended | moderate | --- | not needed | Recommended update for opera
openSUSE-Leap-15.0-Update-Non-Oss | openSUSE-2018-1294 | recommended | low | --- | not needed | Recommended update for Regina-REXX, THE, ooRexx
openSUSE-Leap-15.0-Update | openSUSE-2018-1000 | recommended | moderate | --- | not needed | Recommended update for gnuhealth, proteus, tryton, trytond, trytond_purchase, trytond_stock_supply
openSUSE-Leap-15.0-Update | openSUSE-2018-1007 | recommended | moderate | --- | applied | Recommended update for tigervnc
Repository | Name | Category | Severity | Interactive | Status | Summary
在使用 vim 中的语法高亮规则检查分隔符是否是空格和制表符的组合时,它只返回空格。
:syntax on
:set syntax=whitespace
似乎该文件可能使用多个分隔符。
- 确定正在使用的分隔符的最有效方法是什么?
- 根据使用的分隔符对列进行排序的最佳和最简单的方法是什么?
这应该可以,除非您想保留标题:
如果文件经常使用空格(即它不混合and ),您可以省略("ignoreleading blanks)
-b
选项。sort
| applied
| applied
但我猜a)该程序可能有一些选项可以将其格式调整为更机器可读的东西b)你会更好,例如。
awk -F'|' '$6~/not needed/'
而不是sort
.你可以使用这个:
它继续
awk
运行listing.txt
;相反,您可以将数据输入awk
(listing.txt
当然,最后省略)。-script 按原样打印前awk
四个标题行。其余的行通过管道传输到sort
.Sort
对第 6 列进行排序,使用等于管道符号的分隔符对其进行标识。