I have some code like
#!/bin/bash
DIR='/project/stnb'
HOST_CONFIG="${DIR}/config/host.$(hostname -s).php"
CT_NUMBER="$(grep -Pow --max-count=1 ct'[0-9]*' ${HOST_CONFIG})" #number of container
BASH_PROFILE_PS_STING="PS1='\[\e[0;32m\]\u\[\e[0;32m\]@\[\e[0;36m\]${CT_NUMBER}\[\e[0;33m\]\w\[\e[0;36m\]\$(__git_ps1 \"(%s)\") \[\e[0m\]\$ '"
so I want to rewrite 1st row at "bash_profile", and try "sed"
sed -i "1с${BASH_PROFILE_PS_STING}" ~/.bash_profile
but after replacing I see only
PS1='[e[0;32m][e[0;32m]@[e[0;36m]ct88[e[0;33m]w[e[0;36m]$(__git_ps1 "(%s)") [e[0m]$ '
After googling I was try following options:
1) Use an alternate regex delimiter
sed -i "1s!.*!${BASH_PROFILE_PS_STING}!" ~/.bash_profile
2) or
sed -i "1c~${BASH_PROFILE_PS_STING}" ~/.bash_profile
what's wrong? Is it really necessary to preliminary replace \ in variable before and replace change after operation back?