Category Archives: Blech

This is the default catagory and should be avoided. If there is something in this catagory it means either it should be catagorized into one of the other catagories or there needs to be a new catagory created to encompass the post in question.

Useful bash Line for Debugging

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!

Share

HowTo: Copy an Array in bash

If you want to make a copy of an array as an array in bash, you must use this specific syntax in order to get the elements parsed as individual elements.

##

export -a "$newArray=(${oldArray[*]})"

#

The asterisk gives access to each element within the original array, and the parentheses ensure the new array is populated also as an array with multiple elements.

Share