gpt4 book ai didi

linux - 如何处理单引号之间双引号中有空格的变量

转载 作者:太空宇宙 更新时间:2023-11-04 12:50:37 24 4
gpt4 key购买 nike

这是我的:

#!/bin/sh
var="file1 is installed\n\n"
var=$var"file2 is installed"

...

su $USER -c 'export DISPLAY=0:0;zenity --info --text="<span size=\"large\">pylink library has been installed.</span>\n\nFiles are installed to: $* --title="eyelink_core lib" --ok-label="Ok"' "$var"

but when I run it, I always get: file1 is installed\n\nfile2 is installed: -c: line 0 unexpected EOF while looking for matching '"'

谁知道怎么解决?谢谢!

最佳答案

\n 在双引号字符串中没有被特殊对待。请改用 ANSI 引号。

var=$'file1 is installed\n\n'

或者,简单地按字面意思嵌入换行符:

var="file1 is installed

"

关于linux - 如何处理单引号之间双引号中有空格的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37308738/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com