5 echo命令的作用

2021-10-05 15:02:24 字數 1741 閱讀 6639

echo "my namme is pning"
這裡的雙引號可以省略

echo my namme is pning
執行結果

echo "\"my name is pning\""
此處雙引號也可以省略

echo \"my name is pning\"
執行結果

demo.sh示例

#!/bin/sh

read name

echo "$name it is my name"

read name的意思是在輸入中讀取一行,並把輸入行的每個欄位的值指定給變數name執行示範

注意:echo 自動新增換行符

#!/bin/sh

echo "----------------換行符------------------"

echo "----------有加-e-------"

echo -e "pning is my name \n"

echo "-----無加-e,即預設-e---"

echo -e "pning is my name \n"

echo "----------------不換行符------------------"

echo "----------有加-e-------"

echo -e "pning is my name \c"

echo "-----無加-e,即預設-e---"

echo -e "pning is my name \c"

執行結果

首先建立乙個空白檔案

demo.sh示例

#!/bin/sh

name="pning"

echo -e '/"pning is my $/" \n'

執行例項

注意:換行符是可以起作用的

demo.sh示例

echo `date`
注意:不是單引號,而是反引號

執行結果

linux中的echo命令

承接上一章所介紹的command line 這裡我們用echo這個命令加以進一步說明。標準的command line包含三個部件 command name options argument echo是乙個非常簡單 直接的linux命令 將argument送出至標準輸出 stdout 通常就是在顯示器...

Linux中的echo命令

1,覆蓋型寫法 檔案裡原來的內容被覆蓋 echo aaa a.txt echo aaa a.txt 2,新增型寫法 新內容新增在原來內容的後面 echo aaa a.txt echo aaa a.txt 其中 echo or file,在 user space 中會賦值到 buf 中為 string...

shell中的echo命令

echo 是乙個 shell 內建命令,用來在終端輸出字串 root server1 mnt sh test.sh students,你好!root server1 mnt cat test.sh bin bash name shell教程 url echo students,你好!直接輸出字串 e...