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 ?
>&2
s) and the usual advice is to useprintf
instead ofecho
for any printing (see https://unix.stackexchange.com/a/65819/133219). – Ed Morton Apr 29 '21 at 13:47slowprint () { for c in "$@" ; printf "%s" "$c" ; sleep 0.2 ; done ; printf "\n" ; }
. Then you can runslowprint C O M A T O S E
whenever you want. – cas Apr 29 '21 at 14:55slowprint '*' '*' '*' '*' '*'
. and, yes, i forgot thedo
in the for loop, your version fixed it. – cas Apr 29 '21 at 17:10https://shellcheck.net
, a syntax checker, or installshellcheck
locally. Make usingshellcheck
part of your development process. – waltinator Apr 29 '21 at 17:19