Score:0

using yum list package, show only the package name without x86_64 and version number without 4.el7

us flag

please help me, i want using yum list package, show only the package name without x86_64 and version number without 4.el7.

I don't want to use rpm -qa --qf , because yum more accurate.

yum list installed
The output:
ModemManager.x86_64                   1.6.10-4.el7
ModemManager-glib.x86_64              1.6.10-4.el7
NetworkManager.x86_64                 1:1.18.8-2.el7_9
NetworkManager-adsl.x86_64            1:1.18.8-2.el7_9
NetworkManager-config-server.noarch.  1:1.18.8-2.el7_9

and I want the output be like this:

ModemManager                  1.6.10
ModemManager-glib             1.6.10
NetworkManager                1.18.8
in flag
not sure what option `--qf` means. but haven't you tried to use `| grep -vE ".x86_64|4.el7"`or `grep "noarch"` ?
us flag
do you mean - yum list installed | grep -vE ".x86_64|4.el7" ?
in flag
yes, or you want to use `| sed -e 's/4.el7.*//g' -e 's/.x86_64//g` to remove specified text of every line ?
us flag
Yes, I want to remove them from the lines
in flag
give me an example output of what you get and then what the output should look like, then I can halp you
in flag
pls add this to your post and not the comments
Score:0
hk flag

yum list installed | awk 'NR>2' | cut -d' ' -f1

Adjust the awk/cut parameters based on your output.

Score:0
in flag

For the following example you have to add or change the sed parameters depending on the output you want to have.

yum list installed | \
sed -e 's/.x86_64//g'  \
-e 's/.noarch//g' \
-e 's/-[[:digit:]].el7_9//g' \
-e 's/-[[:digit:]].el[[:digit:]]//g'

This will remove all entries of .x86_64 .noarch -[0-9].el7_9 -[0-9].el[0-9]

us flag
thanks, I will try it.
us flag
Unfortunately , It is working for some lines only
in flag
which lines doesn't work ?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.