Without using brew, how can I detect if coreutils is installed on the mac where my bash script is running.
here is my script:
#!/usr/bin/env bash
check_bash_version () {
echo "checking which bash version is installed...."
sleep 3
echo "Bash versioncheck completed"
sleep 1
if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
echo "You need to be using Bash version =< 4. Please upgrade"
exit 1
fi
}
check_coreutils () {
echo "checking if coreutils is installed...."
sleep 3
# what goes here
}
main() {
# Main function.
# check if MacOS
if [[ "$(uname)" == "Darwin" ]]; then
check_bash_version
check_coreutils
fi
}
--versionof this tool. 3. Check if the output has the string GNU in it.You need to be using bash version >= 4.