Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 在提示之前删除换行符_Unix_Prompt - Fatal编程技术网

Unix 在提示之前删除换行符

Unix 在提示之前删除换行符,unix,prompt,Unix,Prompt,如何在提示之前删除新行。 我不知道该如何表述这个问题,所以这里有一个例子 我想从 %>回显“你好,世界” 你好,世界 %> 到 %>回显“你好,世界” 你好,世界%> 我尝试用sed的/\\n/'替换新行。即使使用\\r和tr。 也许切割功能会准确 echo-n我得到的方法 回声-n“你好,世界” hello world%#注意刚刚出现的新字符% %> 您可以使用不会添加下线的-n开关 echo -n "hello world" 你可以这么做 printf "hello world" 或

如何在提示之前删除新行。 我不知道该如何表述这个问题,所以这里有一个例子

我想从

%>回显“你好,世界”
你好,世界
%>

%>回显“你好,世界”
你好,世界%>
我尝试用sed
的/\\n/'
替换新行。即使使用
\\r
tr
。 也许切割功能会准确

echo-n
我得到的方法

回声-n“你好,世界” hello world%#注意刚刚出现的新字符% %>
您可以使用不会添加下线的
-n
开关

echo -n "hello world"

你可以这么做

printf "hello world"

或者,更好的方法是:
printf“%s”的“hello world”
。(不要将任意的第一个参数传递给
printf
——事情会变得有趣。)