Printf example in bash does not create a newline

前端 未结 8 1726
臣服心动
臣服心动 2020-12-09 08:20

Working with printf in a bash script, adding no spaces after \"\\n\" does not create a newline, whereas adding a space creates a newline, e. g.:

8条回答
  •  悲哀的现实
    2020-12-09 08:48

    $ printf -v NewLine "\n"
    $ echo -e "Firstline${NewLine}Lastline"
    
    Firstline
    Lastline
    
    $ echo "Firstline${NewLine}Lastline"
    Firstline
    Lastline
    

提交回复
热议问题