Sed can't see my PS1

I’m trying to use sed as root to alter the default PS1
The first 2 lines were just to make sure I had the syntax structured right and to see if the quotation marks made a difference,
running them consecutively allows me to change a comment near the top of the file and then change it back.
Opening the file in nano confirms the changes are effective, which should rule out ‘write permissions’.

sed -i 's/If not running interactively,/stringtoreplaceitwith/' /etc/skel/.bashrc

sed -i "s/stringtoreplaceitwith/If not running interactively,/" /etc/skel/.bashrc

sed -i "s/\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ /Replace PS1/" /etc/skel/.bashrc

I’m not sure if it’s something else about the string’s structure,
but for some reason,

It is the structure of what I’m wanting to substitue, sed sees the brackets [ ] as a range.
it’s not finding what I’d like to substitute
Is there a way to escape the brackets?


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.