我如何在鱼壳的字符串中使用换行符?

问题描述 投票:1回答:1

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视为换行符而不是文字。

string line-breaks fish
1个回答
1
投票
  1. Fish用换行符将引号之外的\n替换为新行,因此您可以停止并重新启动引号(请注意在引号之前不要包含“ $”:]

'这是一行'\ n'这是另一行'

  1. 鱼在行之间加上引号,因此您可以包括文字换行符:

'this is line this is another line'

© www.soinside.com 2019 - 2024. All rights reserved.