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
@thann
mod
admin
link
fedilink
1
edit-2
4M

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 >)

@thann
mod
admin
link
fedilink
14M

this: <<EOF is called a “here-doc”, and variable interpolation works in it =\

Ask specific questions about how to code something in sh, bash, zsh, etc

General bash discussion on lemmy.ml

Create Post From:
lemmy.ml

  • 0 users online
  • 2 users / day
  • 2 users / week
  • 2 users / month
  • 5 users / 6 months
  • 17 subscribers
  • 9 Posts
  • 17 Comments
  • Modlog