小编Raf*_*sin的帖子

bash 中单引号 $'string' 和双引号 $"string" 有什么区别?

我试图使用执行新行echo并尝试执行以下两个命令:

  1. 第一条命令:

    echo $'Hello World\nThis is a new line'
    
    Run Code Online (Sandbox Code Playgroud)

    回复:

    Hello World
    This is a new line
    
    Run Code Online (Sandbox Code Playgroud)
  2. 第二个命令:

    echo $"Hello World\nThis is a new line"
    
    Run Code Online (Sandbox Code Playgroud)

    回复:

    Hello World\nThis is a new line
    
    Run Code Online (Sandbox Code Playgroud)

我的问题是$' '$" "in包裹的字符串与用bash's包裹的字符串有什么区别echo

bash echo quoting

11
推荐指数
2
解决办法
2880
查看次数

声明:-A:无效选项

declare: -A: invalid option在声明以下地图时收到此错误

declare -A ApiResourcePath_LambdaFunc_Map=( \
    [signup]="CreateUser" \
    [verify-user]="VerifyUser" \
    [login]="Login" \
    [change-password]="ChangePassword" \
    [forgot-password]="LostPassword" \
    [reset-password]="ResetPassword" \
    [refresh-token]="RefreshToken" \
)
Run Code Online (Sandbox Code Playgroud)

我在这里没有发现任何语法错误。为什么我收到这个错误?

bash shell-script

3
推荐指数
1
解决办法
3251
查看次数

标签 统计

bash ×2

echo ×1

quoting ×1

shell-script ×1