Last active
April 24, 2020 09:02
-
-
Save peter279k/cc738446699f1015b9a70ef031420a9d to your computer and use it in GitHub Desktop.
Find OS released dist name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Now it's available for Debian, Ubuntu, RedHat, CentOS and Fedora. | |
folder_root='/etc/' | |
dist_name='Unknown OS dist name' | |
release_paths=$(ls $folder_root 2>/dev/null | grep '\-release') | |
for release_path in $release_paths; | |
do | |
dist=$(cat ${folder_root}${release_path} | grep 'DISTRIB_DESCRIPTION=') | |
if [ $? != 1 ]; then | |
dist_name=$(echo $dist | sed -e 's/DISTRIB_DESCRIPTION=//g' | sed -e 's/"//g') | |
break; | |
fi; | |
dist=$(cat ${folder_root}${release_path} | grep 'PRETTY_NAME=') | |
if [ $? != 1 ]; then | |
dist_name=$(echo $dist | sed -e 's/PRETTY_NAME=//g' | sed -e 's/"//g') | |
break; | |
fi; | |
done; | |
echo $dist_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment