How to escape a single quote in single quote string in Bash?

后端 未结 3 1119
广开言路
广开言路 2020-11-30 02:58

I want to display a string in Bash like this

I\'m a student

Of course you can do it like this

echo \"I\'m a student\"
<         


        
3条回答
  •  孤独总比滥情好
    2020-11-30 03:26

    The example below works because the escaped single quote \' is technically between two single-quoted arguments

    echo 'I'\''m a student'
    

提交回复
热议问题