Skip to content


iterate through array

ARRAY=(a b c)
for a in "${ARRAY[*]}"; do echo "$a";done

address an array by index directly:

echo ${ARRAY[2]}

output will be b

escape strings

echo "text with spaces & special characters" | bash -c 'printf "%q" "$(cat)"'; echo

will output this: text\ with\ spaces\ \&\ special\ characters, now you can go ahead and use it in a script or something like that.

found this somewhere in here

disable history temporarily

because you don't want credentials in your history, you know.

turn history off:

set +o history

turn it back on again:

set -o history