dnf repolist only displays the enabled repos, it does not have a 3rd column. dnf repolist --all shows all installed repos with the 3rd column showing enabled or disabled
There are also other options --enabled (which is the default with no options) and --disabled which only lists the disabled repos.
Knowing what you are asking about helps to narrow down what action you need to work with.
No you are not correct in stating there are 29 spaces between the 1st & 2nd fields. The second field is a column that begins at the same column always and the number of spaces is determined by the number of characters in the first column
Similarly there are not a fixed number of spaces between the 2nd & 3rd columns as that is determined by the number of characters in the second column and padded by spaces to the proper amount for the 3rd column to always begin in the proper column.
Yes this forum strips spaces in regular text, but that can be controlled by using the </> preformatted text tags available on the tool bar when you are entering your post so the entry remains formatted as you see it displayed on your screen.
Note that I edited your post and added the preformatted text tags so that line is seen as it appears on the screen.
Here you can clearly see the number of spaces varies according to the amount of text in the preceding column.
Once again you insult me with your condescending attitude. Drop it, if you come here to answer questions.
If I missed a parameter in my question, it does not mean that I compare apples and oranges.
And yes, I am correct that there are 29 spaces between fedora and Fedora 36. I had counted each of them. That other entries may have a different number of them is inconsequential to this question. The specific figure was only used to augment the formatting by this portal. So, once again, drop the snide attitude. You come across as a very rude and angry peer. This is against this resources code of conduct. I hope moderators take notice.
Unfortunately, it does not because I cannot rely on the assumption that the user has perl installed. This is rather a question of formatting rules than about a programmatic solution to them. Possible answers can include formatting definition rather than code to implement them.
Since this is a Fedora support channel, the assumption is that you’re asking about a currently supported version of Fedora. I can’t guarantee that the same example I gave you will work against CentOS 7 or Mandriva and this wouldn’t be the appropriate place to ask for that. As current versions of Fedora offer perl, that’s an option. You could try porting the regex to sed or python otherwise.
@habono Parsing command output meant for human viewers is always kind of frail. Have you looked at using the DNF API to get the information you want?
I definitely can’t guarantee that the spacing will be the same on all locales — or that we’ll keep the repo names the same. If you really, really want to parse the output, you might want to consider a tool like awk or cut (which are very likely to be installed). These let you work with “fields”, which can be white-space separated.
I can certainly ask questions about the current version but the users of my scripts have no knowledge of any such, now or in the future. I have no way of knowing what they are running and in what configuration.
I’ve found an easy solution: split on the index of the column headers.
There is a presumption, based on the fact that you are asking about output from dnf repolist, that the users of your solution are using fedora and that they will be using the same commands (or at least your scripts will). Thus your scripts would be based on the current dnf outputs and supposedly would have no way to self-modify should the data being processed change format in the future. Someone would need to be able to modify the scripts should the input data change.
To me this seems you do know what your users are running (Fedora) and although you may have no way to know what else they are running, or even what version, your script needs seem to be specifically aimed at Fedora and dnf. Thus claiming ignorance seems short sighted for future support of your users.
Although I have been using fedora for many years (from the very beginning) I have no way to know what changes may have been made in dnf over time and would personally have to do research from the beginning to see the details of changes made. I would anticipate that further changes are likely so whatever I might script/program/build today may not be correct for tomorrows needs. Hopefully things are stable, but who really knows. The need for maintenance should be anticipated.
The comment was made about DNF API, and that seems a reasonable point to base any scripts upon, rather than the text output of some individual dnf command
If those machines have DNF on them, yes. If they don’t, you also don’t have dnf repolist, though, do you?
The DNF API may change, but API changes at least should be versioned and documented. The output isn’t meant for computer consumption, though, so it is very conceivable that some future version will format this differently — or for that matter that past versions already have.
Sure, if that works for you, cool. But there’s no guarantee that those column headers will stay consistent.
I was referring to remote machines that interrogate Fedora hosts with DNF. My scripts access hosts remotely. So I am wondering if they have access to DNF API remotely, from an arbitrary OS that is not Fedora.