Skip to content

Instantly share code, notes, and snippets.

@OAkyildiz
Created December 12, 2017 19:26
Show Gist options
  • Save OAkyildiz/a43eb89efcad64943632d7d58e59bd14 to your computer and use it in GitHub Desktop.
Save OAkyildiz/a43eb89efcad64943632d7d58e59bd14 to your computer and use it in GitHub Desktop.
#Redundant script to check & install packages. Testing line #11 was the only purpose behind this
#!/bin/bash
#Redundant script to check packages.
PKG="$1"
if [ -z "$PKG" ]; then
echo "Package name is required!"
exit 128
fi
# I actually wrote this script to test the line below
if apt -qq list $PKG 2>/dev/null | grep -q installed; then
echo "$PKG is already installed!"
else
echo -n "$PKG was not found! Install?: (y/N)"
read REPLY
if [ "$REPLY" == "y" ]; then
sudo apt-get install $PKG
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment