Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
After the <, a filename is expected. In your case, that filename is cat. Then another string appears, "/etc/os-release". That's the error.
This is a new type of cat abuse. Leave out the cat, and the syntax is correct. However, since the script doesn't read from standard input, it is pointless to redirect it. I believe you want to replace the for loop with something like
Code:
while read line
do if ...
...
done < /etc/os-release
Last edited by berndbausch; 06-17-2020 at 11:40 PM.
OK I worked on this, before I got to read your inputs and new complete code is:
Code:
while read line; do
if [[ "$line" =~ "VERSION_ID=" ]]; then
ver=${line:12:5}
echo "V=> $ver"
fi
done < /etc/os-release
case $ver in
12.04) vername="Precise"
;;
14.04) vername="Trusty"
;;
16.04) vername="Xenial"
;;
18.04) vername="Bionic"
;;
20.04) vername="Focal"
;;
esac
echo "VN=> $vername"
If I have the version names right I can then use this to update my "/etc/apt/sources.list" file by version for all the apps I download, install and use.
Hope that explains what I'm doing here! I see some of you understood what I'm trying to do!
cat /etc/os-release | grep -i version_codename | sed 's/VERSION\_CODENAME\=//'
Although reinventing wheels can be fun sometimes.
this is deprecated, do not use three commands (and two pipes) if a simple oneliner is enough.
You can solve it with grep/sed/awk/perl/python/whatever...
Some of you will probably see a few more I should add, but with version and versionname assigned I now get all the right version appropriate repositories. This could be also modified to run against the original /etc/apt/sources.list to make sure it is calling all ther right version repos, though by default it should.
Cheers!
TBNK
PS
Ok marking this "Solved" but you can still post other repos you like, but please explain why and what programs/packages they enable.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.