Search code examples
linuxsedsolaris

sed command on single line input


I am using SunOS 10. I am trying to replace the : character at the end of line if the word contains : in it.

I am using the below command for it.

echo -n "test:" | sed 's/:$//g'

It's not working. What did I do wrong here?

The same command is working fine in GNU/Linux.


Solution

  • You don't need a line feed. You need to remove that -n

    echo "test:" | sed 's/:$//g'