可以使用以下方法在 centos 中換行:使用轉(zhuǎn)義字符“”;使用換行符 ASCII 碼 (10);使用 printf 命令的“n”格式說(shuō)明符;使用 echo -e 命令。
如何在 CentOS 中換行
一、使用轉(zhuǎn)義字符
最簡(jiǎn)單的方法是使用轉(zhuǎn)義字符“”。在要換行的位置按“”,然后按下回車鍵即可。
示例:
echo "This is a long line. This is the second line."
輸出:
This is a long line. This is the second line.
二、使用換行符
還可以使用換行符 ASCII 碼 (10) 來(lái)?yè)Q行。
示例:
echo "This is a long line.$(printf 'n')This is the second line."
輸出:
This is a long line. This is the second line.
三、使用 printf
printf 命令還可以用于換行。使用 “n” 格式說(shuō)明符:
示例:
printf "This is a long line.nThis is the second line.n"
輸出:
This is a long line. This is the second line.
四、使用 echo -e
echo -e 命令允許識(shí)別轉(zhuǎn)義序列,包括換行符。
示例:
echo -e "This is a long line.nThis is the second line."
輸出:
This is a long line. This is the second line.
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END