How does the leading dollar sign affect single quotes in Bash?

后端 未结 3 2065
一生所求
一生所求 2020-11-29 20:54

I need to pass a string to a program as its argument from the Bash CLI, e.g

program \"don\'t do this\"

The string may include any character

3条回答
  •  渐次进展
    2020-11-29 21:30

    It causes escape sequences to be interpreted.

    $ echo $'Name\tAge\nBob\t24\nMary\t36'
    Name    Age
    Bob     24
    Mary    36
    

    (And SO handles tabs in a goofy manner, so try this one at home)

提交回复
热议问题