本篇文章给大家介绍的内容是关于如何在bash shell中使用换行符(n),下面我们就来看具体的内容。
我们首先来看一下命令
使用以下命令在bash shell脚本中使用n打印换行符。
printf “first linensecond linen”
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"
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END