Skip to content

Instantly share code, notes, and snippets.

@it3xl
Last active May 8, 2022 14:42
Show Gist options
  • Save it3xl/e4d5c5113f99b02ec84e4a6987c5ead2 to your computer and use it in GitHub Desktop.
Save it3xl/e4d5c5113f99b02ec84e4a6987c5ead2 to your computer and use it in GitHub Desktop.
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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment