Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

linux echo命令的-n、-e兩個參數

 echo -n 不換行輸出


$echo -n "123"
$echo "456"

最終輸出 
123456

而不是
123
456

echo -e 處理特殊字符

若字符串中出現以下字符,則特別加以處理,而不會將它當成一般文字輸出:
\a 發出警告聲;
\b 刪除前一個字符;
\c 最後不加上換行符號;
\f 換行但光標仍舊停留在原來的位置;
\n 換行且光標移至行首;
\r 光標移至行首,但不換行;
\t 插入tab;
\v 與\f相同;
\\ 插入\字符;
\nnn 插入nnn(八進制)所代表的ASCII字符;

$echo -e "a\bdddd"
dddd

$echo -e "a\adddd" //輸出同時會發出報警聲音
adddd


$echo -e "a\ndddd" //自動換行
a
dddd


http://patorjk.com/software/taag/#p=display&h=0&v=0&f=Big&t=HELLO