Ubuntu: append line command not working in terminal


I am trying to append CDPATH automatically in the ~/.bash_profile and I am doing it by using the command

ex -sc 's/$/:/opt/|w|q' ~/.bash_profile  

When I run this, the terminal hangs whereas the below command works just fine

ex -sc 's/$/yourText2/|w|q' ~/.bash_profile  

What is wrong in the first command?


The issue is the unescaped / in your replacement text :/opt

You must either escape it

ex -sc 's/$/:\/opt/|w|q' file  

or use an alternate separator for the s command

ex -sc 's@$@:/opt@|w|q' file  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »