Let's begin our activity:
- Open a new terminal and a new file with your preferred editor. Add in the following contents into the new script and save it as builtin-str.sh:
#!/bin/bash# Let's play with variable arrays first using Bash's equivalent of substrSTR="1234567890asdfghjkl"echo "first character ${STR:0:1}"echo "first three characters ${STR:0:3}"echo "third character onwards ${STR: 3}"echo "forth to sixth character ${STR: 3: 3}"echo "last character ${STR: -1}"# Next, can we compare the alphabeticalness of strings?STR2="abc"STR3="bcd"STR4="Bcd"if [[ $STR2 < $STR3 ]]; then echo "STR2 is less than STR3"else echo "STR3 is greater than STR2"fi# Does case have an effect? Yes, b is less than Bif [[ $STR3 < $STR4 ]]; then echo ...