Welcome to Shell Scripting Challenge 002! In this challenge, we have created a simple Bash script with pre-increment, post-increment and a modulus operator. Please try to predict the output of the script. Shell scripting is not only to do practical tasks but also fun when you start working on it
Below is the script for Challenge 002:
Advertisement
#!/bin/bash
x=12
((x++))
((++x))
((x%3))
echo $((x++))
Take a moment to read the script and make your prediction. You can use the notepad to calculate the result. What will be printed to the console when this script is executed? Take into account the use of increment operators and arithmetic expansion in Bash scripting.
Put your scripting skills to the test and see if you can accurately guess the output without running the script. Good luck!