Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Echo woes with variable expansion

I want to append the string PROMPT_COMMAND='echo -ne \"\033]0;${USER}@${HOSTNAME}: ${PWD}\007\"' to the end of a .bashrc file across 4300 servers.

I'm having some difficulty in escaping, obviously I want the variables to not expand when being appended to the file so that the text is kept original.

How might I do so? I tried adding slashes to the beginning of the variables, but that didn't seem to be what I wanted.

like image 718
user2305125 Avatar asked Dec 05 '25 13:12

user2305125


1 Answers

Might be better to use a heredoc

cat >> .bashrc <<'+'
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
+
like image 145
Zombo Avatar answered Dec 07 '25 04:12

Zombo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!