Skip to content

Instantly share code, notes, and snippets.

@SofianeHamlaoui
Created September 11, 2019 22:54
Show Gist options
  • Save SofianeHamlaoui/dd0439429b76bd9e59e6d428a6c6b275 to your computer and use it in GitHub Desktop.
Save SofianeHamlaoui/dd0439429b76bd9e59e6d428a6c6b275 to your computer and use it in GitHub Desktop.
Check what linux package manager is used [BASH]
function apt {
which apt > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
apt install THEPACKAGES
}
function pacman {
which pacman > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
pacman -S THEPACKAGES
}
function zypper {
which zypper > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
zypper install THEPACKAGES
function dnf {
which dnf > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
dnf install THEPACKAGES
}
function yum {
which yum > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
yum install THEPACKAGES
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment