I’ve started using this little code snippet to help debug problems within a bash script. It just shouts out the line where it appears when called. This is useful when you are trying to determine where a problem is located within the various twists and turns of the function calls within a script.
## # Here is a print statement useful in debugging: printf '%s\n' "" "${LINENO}" "" # Pepper a script with those to see where your having trouble line-by-line! ##
Have fun with that!