Open up a new script calledecho-mayhem.shin your favorite editor and a new terminal. Enter the following contents and then execute the script at the prompt:
#!/bin/bash
# What about echo? echo -n "Currently we have seen the command \"echo\" used before" echo " in the previous script" echo echo -n "Can we also have \t tabs? \r\n\r\n?" echo " NO, not yet!" echo echo -en "Can we also have \t tabs? \r\n\r\n?" echo " YES, we can now! enable interpretation of backslash escapes" echo "We can also have:" echo -en '\xF0\x9F\x92\x80\n' # We can also use \0NNN for octal instead of \xFF for hexidecimal echo "Check the man pages for more info ;)"
After reviewing the results of echo-mayhem.sh, create another script called printf-mayhem and enter the following contents:
#!/bin/bash export LC_NUMERIC="en_US.UTF-8" printf "This is the same as echo -e with a new line (\\\n)\n"
DECIMAL=10.0 FLOAT=3.333333 FLOAT2=6.6666 # On purpose two missing values
printf "%s %.2f\n\n" "This is two decimal places: " ${DECIMAL}