I need to evaluate this variables before appending this lines to a few files:
sudo tee -a /etc/profile /etc/zshenv /etc/zsh/zshenv &>/dev/null <<EOF
export XDG_CONFIG_HOME="$SYNC"/config
export XDG_CACHE_HOME="$HOME"/.cache
export XDG_DATA_HOME="$HOME"/.local/share
export XDG_STATE_HOME="$HOME"/.local/state
export ZDOTDIR="$XDG_CONFIG_HOME"/zsh
EOF
tee
is useful for sending stdin to a file AND stdout, if you want to just write to a file you can do:cat <<EOF > /tmp/file_to_write stuff $VAR etc EOF
EDIT: to append use this top line:
cat <<EOF >> /tmp/file_to_write
(double >)this:
<<EOF
is called a “here-doc”, and variable interpolation works in it =\