linux echo 用法 【 -e \c 體會】


echo -e "this is line1\c"  "excepted:this is also the line1"

---->this is line1

=======為什么會這樣呢

man  echo 后發現 在echo -e 后,對“\c” 的解釋是:produce no further output  不產生進一步的輸出   ----》自己理解是在\c 后,這一行后面的內容都不會輸出,直接刪掉了

 

再次測試

echo -e "this is line1 \c  these word will disappear"

---->this is line1

 

完全正確!!!

 

【produce

[prəˈdju:s]       [prəˈdu:s]     

vt.& vi.   產生;       生產;       制作;       創作   

vt.   制造;       出示;       引起;       [經濟學]生利   

n.   產品;       產量;       產額;       結果   

網絡 發生;   農產品;  】

 

echo  "test1" test2 "test3"

---->test1 test2 test3

 

echo -e  "this is line1\n"  "Excepted:this is line2"

---->this is line1

---->this is line2

 

man echo:

 

ECHO(1)                          User Commands                         ECHO(1)

NAME        echo - display a line of text

SYNOPSIS        echo [SHORT-OPTION]... [STRING]...        echo LONG-OPTION

DESCRIPTION        Echo the STRING(s) to standard output.

       -n     do not output the trailing newline

       -e     enable interpretation of backslash escapes

       -E     disable interpretation of backslash escapes (default)

       --help display this help and exit

       --version               output version information and exit

       If -e is in effect, the following sequences are recognized:

       \\     backslash

       \a     alert (BEL)

       \b     backspace

       \c     produce no further output

       \e     escape

       \f     form feed

       \n     new line

       \r     carriage return

       \t     horizontal tab

       \v     vertical tab

       \0NNN  byte with octal value NNN (1 to 3 digits)

       \xHH   byte with hexadecimal value HH (1 to 2 digits)

       NOTE: your shell may have its own version of echo, which usually super‐        sedes the version described here.  Please refer to your  shell's  docu‐

 

 

 

【轉】http://www.cnblogs.com/perfy/archive/2012/07/24/2605903.html

 

 

linux的echo命令, 在shell編程中極為常用, 在終端下打印變量value的時候也是常常用到的, 因此有必要了解下echo的用法
echo命令的功能是在顯示器上顯示一段文字,一般起到一個提示的作用。 該命令的一般格式為: echo [ -n ] 字符串 其中選項n表示輸出文字后不換行;字符串能加引號,也能不加引號。用echo命令輸出加引號的字符串時,將字符串原樣輸出;用echo命令輸出不加引號的字符串時,將字符串中的各個單詞作為字符串輸出,各字符串之間用一個空格分割。
功能說明:顯示文字。 語   法:echo [-ne][字符串]或 echo [--help][--version] 補充說明:echo會將輸入的字符串送往標准輸出。輸出的字符串間以空白字符隔開, 並在最后加上換行號。 參   數:-n 不要在最后自動換行 -e 若字符串中出現以下字符,則特別加以處理,而不會將它當成一般 文字輸出:    \a 發出警告聲;    \b 刪除前一個字符;    \c 最后不加上換行符號;    \f 換行但光標仍舊停留在原來的位置;    \n 換行且光標移至行首;    \r 光標移至行首,但不換行;    \t 插入tab;    \v 與\f相同;    \\ 插入\字符;    \nnn 插入nnn(八進制)所代表的ASCII字符; –help 顯示幫助 –version 顯示版本信息

 

 

-----------------------------------------------------------------------------------------------

 

Linux的echo命令, 在shell編程中極為常用, 在終端下打印變量value的時候也是常常用到。

比如:echo可用作顯示注釋,用於一些批命令中需要注釋給用戶看的地方,比如前一條命令執行會花很長時間,常會用echo顯示一條信息讓用戶知道這個時候比較慢,稍微等待一會。

在Linux中echo命令用來在標准輸出上顯示一段字符,比如: echo "the echo command test!"

這個就會輸出“the echo command test!”這一行文字! 

echo "the echo command test!">a.sh 這個就會在a.sh文件中輸出“the echo command test!”這一行文字! 該命令的一般格式為: echo [ -n ] 字符串其中選項n表示輸出文字后不換行;字符串能加引號,也能不加引號。用echo命令輸出加引號的字符串時,將字符串原樣輸出;用echo命令輸出不加引號的字符串時,將字符串中的各個單詞作為字符串輸出,各字符串之間用一個空格分割。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM