问题– 如何将换行打印为\n
在 bash shell 中?如何使用\n
在 shell 脚本中打印新行。
Issues– 在 bash shell 中回显换行符打印文字\n
但不是新线。打印文字'\n'
在 bash 脚本中的嵌套打印新行中。
Command:
使用以下命令在 bash shell 脚本中使用 \n 打印换行符。 echo 命令还有其他选项。阅读完整的教程。
printf “第一行\n第二行\n”
Bash 中 \n 的使用
\n
(换行)用作基于 Unix 的系统的换行符。下面是在 bash shell 脚本中使用换行符的简单示例。使用以下示例之一
双引号中的字符串:
echo -e "This is First Line \nThis is Second Line"
单引号中的字符串:
echo -e 'This is First Line \nThis is Second Line'
带 $ 前缀的字符串:
echo $'This is First Line \nThis is Second Line'
使用 printf 命令:
printf "This is First Line \nThis is Second Line"
您可能还喜欢我们的bash 脚本编写教程.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)