[英]sed command on single line input
I am using SunOS 10. 我正在使用SunOS 10。
I am trying to replace the :
character at the end of line if the word contains :
in it on SunOs I am using the below command for it. 我想在SunOs的行末尾替换:
字符,如果该单词包含:
我正在使用以下命令。
echo -n "test:" | sed 's/:$//g'
its not working. 它不起作用。 what I did wrong here? 我在这里做错了什么?
The same is working fine in GNU/Linux. 在GNU / Linux中也可以正常工作。
您不需要换行符,您需要删除-n
echo "test:" | sed 's/:$//g'
myshell:/home/myfolderpath # echo -n "test:"|sed 's/:$//g'
testmyshell:/home/myfolderpath#
you code works on my machine. 您的代码可以在我的机器上工作。
because there is no tailing new line.you gonna see the result right before your next shell command line. 因为没有尾随新行。您将在下一个Shell命令行之前看到结果。 -n is not necessary. -n不必要。
myshell:/home/myfolderpath # echo "test:"|sed 's/:$//g'
test
myshell:/home/myfolderpath#
it should be like this without -n 没有-n应该是这样的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.