cat /etc/apt/sources.list | head -n1 | awk '{print $3}'
cat /etc/apt/sources.list | head -n1 | awk '{print $3}'
Simplified to head /etc/apt/sources.list There's a reasonable chance I'll remember it.
Thank you!
bob prohaska
Although often that just picks up a comment, and in any case it's possible to use a "suite name" like stable or testing in sources.list instead of the exact "codename".
There can also be space-separated options before the "suite", as shown in the example from the man page: deb [ option1=value1 option2=value2 ] uri suite [component1] [component2] [...]
If your really want a name, instead of a nice sensible version number, you can read /etc/os-release.
Or print just the name with: expr "`cat /etc/os-release`" : '.*VERSION_CODENAME=\([[:alpha:]]*\)'
Ah yes, that is simpler. I disagree that my command can go wrong, though; not on Raspberry Pi OS, about which the question was asked.
fgrep VERSION_CODENAME /etc/os-release | cut -d= -f2
The sources.list file is something that people often need/want to edit themselves (or possibly copy/paste things like extra repo entries from the web), so I'd consider its formatting to be uncertain on any distro. I usually comment-out the original entries and replace them with alternatives using an Australian (or as close as possible) mirror on the line below.
Each to their own.
Almost no one on any distro will ever edit their sources.list, is my guess. And if you do, you already know where to look.
Sure. And I don't want to say my original version is better, because it isn't, but even if it fails the first time at least you would know where to look for the distro code name. Like Bob changed it: just a full cat of the file.
Simplicity definitely wins here, I think, even with reliance on two external programs. But the insight that that file exists is the most important thing.
Come on, then a whole lot of mirror servers would just be sitting there doing nothing, I'd guess it's one of the most edited files in /etc.
Not really, people may set it up at installation/upgrade, possibly copying/pasting things off a guide on the web, then forget about it until next time.
Unless it just shows "stable" or similar.
"cut" is like a drug. Once you start using it, you then start bolting multiple "cuts" together and before long you've got a monstrosity. Better to always go for a regular expression in the first place when doing this sort of thing, then you're never tempted. But each to their own.
V="`grep VERSION_CODENAME /etc/os-release`" && echo "${V#VERSION_CODENAME=}"
FWIW, experiments with the latest 64-bit release have cleared up the last remnants of misbehavior using chromium to view Youtube.
Those last remnants of misbehavior were erratic audio levels and some amount of distortion via the HDMI output.
Working on a permanent upgrade now.
Thanks for reading,
bob prohaska
or better ...
cat /etc/os-release
Have something to add? Share your thoughts — no account required.
Ask the community — no account required