Home
BaSnake Mac OS

BaSnake Mac OS

May 30 2021

BaSnake Mac OS

Sample bash script to show how to parse the macOS version

MacOS Big Sur supports most Mac models introduced in 2013 and later. View compatible Mac models. Before you upgrade, make a complete backup with Time Machine, or store your files in iCloud. Learn how to back up your Mac. Backup your Mac with Time Machine. There are many reasons that may have influenced your.

os_version.sh
#!/bin/bash
# use argument 1 as the version or get it from sw_vers
os_ver=${1-:$(sw_vers -productVersion)}
# string comparison
if [[ '$os_ver' 10.13.* ]];then
echo'macOS High Sierra'
elif [[ '$os_ver' 10.12.* ]];then
echo'macOS Sierra'
else
echo'(Mac) OS X something'
fi
# regular expression
if [[ '$os_ver'=~ 10.1[23].* ]];then
echo'It's one of the Sierras'
fi
# awk
echo'minor version with awk: '$(echo '$os_ver' awk -F. '{ print $2; }')
echo'patch version with awk: '$(echo '$os_ver' awk -F. '{ print $3; }')
# array
IFS='.'read -r -a ver <<<'$os_ver'
echo'minor version with array: ${ver[1]}'
echo'patch version with array: ${ver[2]}'
# numerical comparison
if [[ '${ver[1]}'-ge 9 ]];then
echo'somewhere in California'
elif [[ '${ver[1]}'-ge 2 ]];then
echo'officially a feline'
else
echo'secretly a feline'
fi
# get the build number:
build_ver=${2-:$(sw_vers -buildVersion)}
if [[ '${ver[1]}'-le 5 ]];then
build_number='${build_ver:3}'
else
build_number='${build_ver:4}'
fi
if [[ ${build_number: -1}'a' ]];then
build_number='${build_number:0:$((${#build_number}-1))}'
fi
echo'build number: $build_number'

commented Mar 5, 2018

Looking at this piece:

I needed to take into account the leading colon in os_ver. To do that I modified my if statement to this

commented Nov 6, 2019

I think it should have been:

(swap -: with :- to set the default)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Upgrade to macOS Big Sur

Before installing this upgrade, make sure that your Mac is ready.

Check compatibility

macOS Big Sur supports most Mac models introduced in 2013 and later.

View compatible Mac models

Make a backup

Before you upgrade, make a complete backup with Time Machine, or store your files in iCloud.

Learn how to back up your Mac

Free up space

If the installer needs more storage space to upgrade, you can free up space using tools that come with your Mac.

Free up storage space

Download macOS Big Sur

If you’re using macOS Mojave or later, choose Apple menu  > System Preferences, then click Software Update. If you’re using an earlier macOS, use the App Store instead.

Learn how to download and install macOS Big SurGo to the App Store

Get to know macOS Big Sur

Learn about some of the new features of macOS Big Sur.

Control Center

Control Center brings favorite controls such as Bluetooth, Wi-Fi, Do Not Disturb, and Sound together in a single place—so you can easily adjust them at any time.

Use Control Center

Notification Center

Ba Snake Mac Os 11

Notification Center puts notifications and>

Safari

Customize your start page, navigate with ease using the new tab bar, and access a new privacy report to see just how Safari protects your privacy as you browse.

Get to know Safari

Maps

Discover great places around the world and navigate easier with guides, cycling directions, indoor maps, Look Around, electric vehicle routing, and more.

Messages

Send messages to friends and family using new tools that make it easier to keep track of group conversations and give you fun, engaging ways to express yourself.

Use MessagesLearn more on YouTubeBaSnake Mac OS

Photos

Use the expanded editing capabilities in Photos to easily make simple changes and more advanced adjustments to your photos.

Learn how to edit your photos

Have a question?

Ba Snake Mac Os X

Ask everyone. Our Apple Support Community can help you find answers.

Ba Snake Mac Os Download

Ask now

Tell us how we can help

Answer a few questions and we'll help you find a solution.

Ba snake mac os downloadGet support

BaSnake Mac OS

Leave a Reply

Cancel reply