Answer the question
In order to leave comments, you need to log in
linux. OS version check
I want to write a script that, depending on the OS (gentoo or deb), installed packages.
There are some sketches, but there is definitely something wrong with them.
#!/bin/sh
WHERE_IS=`whereis lsb_release | awk {'print $2'}`
EMERGE="emerge -av `eix lsb | grep release | awk {'print $2'}`"
if [ -z $WHERE_IS ]; then
echo "$n не существует."
$EMERGE
else
echo "$n существует."
echo $WHERE_IS
fi
Answer the question
In order to leave comments, you need to log in
A decent Skeleton, to the public's judgment:
#!/bin/sh
cmd0=`whereis emerge | awk {'print $2'}`
_new_check_lsb()
{
echo "Какая у вас ОС - Ubuntu или Gentoo? Или Help для того чтобы узнать какая у вас ОС"
read -p "Введите название: " yn
case "${yn,,}" in
gentoo)
echo "test - gentoo"
;;
ubuntu)
echo "test - ubuntu"
;;
help)
if [ "$cmd0" = "" ]; then
echo "Ubuntu"
else
echo "Gentoo"
fi
_new_check_lsb
;;
*)
echo "Вы не чего не ввели"
;;
esac
}
_new_check_lsb
#!/bin/bash
if [ -e /etc/gentoo-release ]; then
echo "Gentoo"
elif [ -e /etc/debian_version ]; then
echo "Debian"
fi
I would take the output of "uname -a" as a basis, unless of course it is too primitive within the framework of the task.
You can also look into the script from virtualbox for guest OSes, as far as I remember, it determines in which OS it is launched, although I could be mistaken, there is no way to look now.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question