Echo tab characters in bash script

后端 未结 10 2110
予麋鹿
予麋鹿 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:19

    If you want to use echo "a\tb" in a script, you run the script as:

    # sh -e myscript.sh
    

    Alternatively, you can give to myscript.sh the execution permission, and then run the script.

    # chmod +x myscript.sh
    # ./myscript.sh
    

提交回复
热议问题