与How can I have a newline in a string in sh?但在鱼壳里。
在shell中,我们有:
$'this is line\nthis is another line'
谁产生了预期的结果,但是在鱼中却不起作用。
鱼也有类似的方法?
编辑1:
具有faho明智地提到的文字方法:
'this is line
this is another line'
但是我真的很好奇这种方法的存在,就像在shell中一样,它保留了对\n
的引用作为换行符。
我想知道我是否可以使用此字符串"this is a line\nthis is another line"
,以确保鱼将\n
视为换行符而不是文字。
\n
替换为新行,因此您可以停止并重新启动引号(请注意在引号之前不要包含“ $”:]'这是一行'\ n'这是另一行'
'this is line
this is another line'