Check for Outdated Terminal App Version in Bash with Visual Studio Code on Mac - VicPhanDevOps/mac GitHub Wiki

• Press the command key and spacebar to launch Spotlight Search, type “terminal” and select the “Terminal” application.
image

• Type cd < directory > and press the return key to change directory to where you’d like to save the Bash script for checking an outdated Terminal app.
image

• Type code < script name >.sh and press the press the return key to create the Bash script in Visual Studio Code.
image

• The blank script will open in Visual Studio Code.
image

• Type #!/bin/bash and press the return key twice to set the shebang.
image

• Type # < comment > and press the return key twice to comment that this script is for checking a Terminal app version.
image

• Type < variable >=$(< get app version command >) and press the return key twice to declare a variable that captures the results of getting the app version.
image

• Type if [[ $< variable > == “< outdated app version >.”* ]]; then and press the return key to check for the outdated version of the app.
image

• Press the tab key to indent, type the command(s) if the app is outdated (I update the app in my example) and press the return key to set the action(s) if the app is outdated.
image

• Press the shift and tab keys to decrease indent, type else and press the return key to define the else statement.
image

• Press the tab key to indent, type command(s) if the app is up-to-update (I print the app version in my example) and press the return key to set the action(s) if the app is current.
image

• Press the shift and tab keys to decrease indent, type fi and press the return key to close the scope of the if statement.
image

• Press the command and S keys to save.
image

• Return to the Terminal, type chmod +x < script name >.sh and press the return key to grant the script execution permission.
image

• Type ./< script name >.sh and press the return key to run the script.
image

⚠️ **GitHub.com Fallback** ⚠️