Splitting Long Strings and Commands in Bash
ns=my_ns my_pod=pod-of-mine zuza='oppa doppa' # As a direct command. kubectl -n $ns exec $my_pod -- sh -c ' \ val="tram '"$zuza"' pam"; \ echo gu '"$zuza"' ga; \ echo la la "$val" la la;' # As a string command. # But use back-slash to make single line commands. my_command=' val="tram '$zuza' pam"; echo '$zuza' we use backslash here to make single line command \ echo la la "$val" la la;' kubectl -n $ns exec $my_pod -- sh -c "$my_command" The same on Gist Github