Shell cat END

Published: Tuesday, Nov 11, 2008 Last modified: Monday, Aug 2, 2021

How not to do it:

essid="test"
key="blah"
cat << END
network={
	ssid="$essid"
	key_mgmt=WPA-PSK
	psk="$key"
}
END > /tmp/bar.txt

How to do it as sudo:

sudo sh -c "cat<> /etc/wpa_supplicant/wpa_supplicant.conf

network={
	ssid="$essid"
	key_mgmt=WPA-PSK
	psk="$key"
}
END"

Thanks #bash on Freenode :)