Dnf's output contains too many space characters

Greetings,
On Fedora 30 when I request a list of packages via dnf command with the command:
‘dnf list’
the output has too much space between the ‘package’ ‘version’ ‘repository’ and I have to set the terminal in full screen to merge the output in one line.
Is there a way to reduce this extra space?

2 Likes

Hi @alextheoto! Welcome to Ask Fedora! Please have a look at the introductory posts in the #start-here category if you haven’t had a chance to do so.

I know of two ways from the top of my head, though I’d say they both aren’t as convenient as dnf list, I use dnf list myself.

One is using rpm --query or -q for short, for example rpm -qa will list all the installed packages. Look at man rpm (also available online) for all the possible query options.

Second is using dnf repoquery. For example you can use

sudo dnf repoquery --qf %{name}-%{version}.%{release}.%{arch} --installed

to get the list of all installed packages similar to rpm’s one above.

Use dnf repoquery --querytags to see all the tags available for output formatting.

See man dnf or online documentation for dnf for all the options available.

You can potentially use alias command to make a shortcut for yourself to use repoquery with the tags you want, for example:

alias my-dnf-ls="dnf -C repoquery --qf %{name}-%{version}.%{release}.%{arch}"

then

my-dnf-ls --installed 'zlib*'

to get the list of all installed packages with name starting with ‘zlib*’

There can be other ways to do what you want as well.


P.S. I’ve altered your topic header a bit to distinguish it from “dnf uses too much disk space” question we’ve had here not that long ago.

2 Likes

The dnf as well as man output should be adaptive to the terminal width on the moment of command invocation unless you redirect it to pipe.

1 Like

I send you one screenshot showing the command
Screenshot_2019-09-10_15-03-48

So it is not terminal’s issue (I think so).
I didn’t have this problem until Fedora 28 which was the last version I used before a pause on Fedora distro. Now I’m back but I have this problem.
The windows are not resized.

Screenshot_2019-09-10_15-08-49
Here is another screenshot with xterm.

I checked more on this problem and when I type ‘dnf list’ the output is within the terminal’s size. But if I type ‘dnf list |grep firefox’ the output is messed up again.
I tested with ‘dnf list > f’ to save the output on file f and the same problem happens.
So, it might be problem with the pipe.
Any idea how to workaround?

You could just use dnf list firefox or dnf list installed fire*_64 etc …?

if you wanted to use grep and just have it separated by spaces following the grep you could just pipe it to

awk ‘{$1=$1;print}’

or you could search with awk

awk ‘/fire/{$1=$1;print}’

1 Like

Thank you grumpey for the hint.
Problem solved.
Thank you very much.

1 Like