Echo tab characters in bash script

后端 未结 10 2138
予麋鹿
予麋鹿 2020-12-07 08:09

How do I echo one or more tab characters using a bash script? When I run this code

res=\'       \'x # res = \"\\t\\tx\"
echo \'[\'$res\']\' # expect [\\t\\tx         


        
10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 08:38

    Using echo to print values of variables is a common Bash pitfall. Reference link:

    http://mywiki.wooledge.org/BashPitfalls#echo_.24foo

提交回复
热议问题