< pre>system_profiler SPSoftwareDataType | grep “System Version” | awk'{print $6}’
either
sw_vers -productVersion
Operating system (abbreviation…Example 10.7)
system_profiler SPSoftwareDataType | grep "System Version" | awk'{print $6}' | sed "s:.[[:digit: ]]*.$::g"
or
OS_Version=$(OS (short… example 10.7) | sed "s:.[[ :digit:]]*)
Celebration:
#!/bin/bash
# Use one of the examples given above to create the OS_Version variable
if [[ ${OS_Version} == 10.7.3 ]]; then
echo "Operating System is a match... will continue on."
else
echo "Operating System is NOT a match... will NOT continue."
fi
I am working on Mac OS X Lion 10.7 write a bash script, I want to know how to check the version of the operating system in bash, if the version is 10.7.1, then it will execute the command and continue to use the script and do the same thing for a different version let’s say 10.7 .3 Then it executes a different command and then uses the command of 10.7.1?
OS_Version(Complete…Example 10 .7.3)
system_profiler SPSoftwareDataType | grep "System Version" | awk'{print $6}'
either
sw_vers -productVersion
Operating system (referred to as…Example 10.7)
system_profiler SPSoftwareDataType | grep "System Version" | awk'{print $6}' | sed "s:.[[:digit:]]*.$::g"
or
OS_Version =$(OS (short… example 10.7) | sed "s:.[[:digit:]]*)
Celebration:
#! /bin/bash# Use one of the examples given above to create the OS_Version variable
if [[ ${OS_Version} == 10.7.3 ]]; then< br /> echo "Operating System is a match... will continue on."
else
echo "Operating System is NOT a match... will NOT continue."
fi pre>