As a part of my bash routine I am printing some message in terminal regarding status of the workflow. The message in splited into two parts (part 1: begining of the task, part 2: status of its finishing)

echo -n "Dataset is being processed ! "; execution of some AWK script; echo " Processing has been COMPLETED!"

Here is realisation in bash contained a part of the AWK code:

# print pharase 1: initiation of the process
echo -n "Dataset is being rescored.. Please wait"; sleep 0.5 
# this is the process: makedir for the result and execute AWK code to process input file
mkdir ${results}
# Apply the following AWK code on the directory contained input file
while read -r d; do
awk -F, '
}'  "${d}_"*/target_file.csv > "${results}/"${d%%_*}".csv"
done < <(find . -maxdepth 1 -type d -name '*_*_*' | awk -F '[_/]' '!seen[$2]++ {print $2}')
# print pharase 2: finish of the result, which would appear in the terminal near phrase 1
# this will print "COMPLETED" letter-by-letter with the pause of 0.2 sec between each letter
echo -n " C"; sleep 0.2; echo -n "O"; sleep 0.2; echo -n "M"; sleep 0.2; echo -n "P"; sleep 0.2; echo -n "L"; echo -n "E"; sleep 0.2; echo -n "T"; echo -n "E"; sleep 0.2; echo "D!"

While executing this script in bash, everything seems to be OK and I have not noticed any problems related to the parts of the code between both 'echo -n' blocks. May such splitting of the status phrase using "echo -n" lead to some bugs of the routine in bash ? Any suggestions for realisation of such status message in bash using another syntax?

  • 2
    \$\begingroup\$ Micro-review - printf %s is more portable than echo -n. \$\endgroup\$ – Toby Speight Apr 29 at 14:03
  • \$\begingroup\$ Thanks! should I so substitute all ECHO parts of my code to printf when I use it to print some messages in terminal during script execution ? What is the advantae of using printf >&2 ? Cheers \$\endgroup\$ – Hot JAMS Apr 30 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.