Complete the code to print the length of the string stored in variable 'text'.
echo ${#[1]The syntax ${#variable} returns the length of the string stored in variable. Here, text is the variable holding the string.
Complete the code to extract the first 4 characters from the string in variable 'word'.
echo ${word:[1]:4}In bash, ${variable:start:length} extracts a substring. Starting at index 0 extracts from the beginning.
Fix the error in the code to replace all occurrences of 'a' with 'o' in variable 'text'.
echo ${text//[1]/o}The syntax ${variable//pattern/replacement} replaces all occurrences of pattern with replacement. Here, 'a' is replaced by 'o'.
Fill both blanks to create a substring from variable 'data' starting at index 2 with length 5.
echo ${data:[1]:[2]The syntax ${variable:start:length} extracts a substring. Here, start is 2 and length is 5.
Fill all three blanks to create a new string with 'Hello' replaced by 'Hi' in variable 'greeting', then print its length.
new=${greeting/[1]/[2]
echo ${#[3]First, replace 'Hello' with 'Hi' in 'greeting' and store in 'new'. Then print length of 'new' using ${#new}.