如何在Bash Shell中使用换行符( )

本篇文章给大家介绍的内容是关于如何在bash shell中使用换行符(n),下面我们就来看具体的内容。

如何在Bash Shell中使用换行符( )

我们首先来看一下命令

使用以下命令在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"

本篇文章到这里就已经全部结束了,更多其他精彩内容可以关注php中文网的linux教程视频栏目!

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享