All
i am struggling to raplace some text in a line between two (closest) patterns ,
line="/home/usr/bin/:/home/usr/devuser,n1.9/bin:/home/usr/root/bin"
i want to replace "devuser,n1.9" with "NEWVAL", basically all teh text from "devuser" until nearest '/' with some new text.
i tried teh following
echo $line | sed 's/devuser.*\//NEWVAL\//'
i am getting /home/usr/bin/:/home/usr/NEWVAL/bin"
where i am expecting
/home/usr/bin/:/home/usr/NEWVAL/bin:/home/usr/root/bin"
i know sed will match the longest possible pattern, i tried this as well
echo $line | sed 's/devuser.*[^\/]/NEWVAL/'
but still no luck
any help will be appreciated.
Thanks in advance.
---------- Post updated at 02:13 AM ---------- Previous update was at 01:30 AM ----------
hey guys,
found something
echo $line | sed 's/devuser[^\/]*/NEWVAL/'
is giving me the expected output.
any other suggestions are welcome.