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

Comments

Popular posts from this blog

Convention over Git = CoG

jQuery Deferred Object method chain or a Syntactic Sugar

Ctrl+Shift+Right arrow doesn't work in Visual Studio 2019