1.命令
read 【選項】【變數名】
選項
2.練習:-p 在等待read輸入時,輸出提示資訊
-t 秒數:read命令會一直等使用者輸入,使用此選項可以指定等待時間
-n 字元數:read命令只接受指定的字元數,就會執行
-s 隱藏輸入的資料,適用於機密資訊的輸入
2.1 -p 選項
2.1 -t 選項、-s選項[root@catyuan ~]# vim /root/read.sh
#!/bin/bash
read -p "please input your name:" name
echo $name
[root@catyuan ~]# chmod 755 /root/read.sh
[root@catyuan ~]# /root/read.sh
please input your name:haha ##冒號後面是由自己去輸入
haha
2.3 -n 選項[root@catyuan ~]# vim /root/read.sh
#!/bin/bash
read -p "please input your name:" -t 30 name
echo $name
read -p "please input your passwd:" -s passwd ##這樣設定之後我們在輸入密碼時不會輸出到螢幕上
echo -e "\n" ##識別換行符要加-e
echo $passwd
[root@catyuan ~]# /root/read.sh
please input your name:haha
haha
please input your passwd:
haha
[root@catyuan ~]# vim /root/read.sh
#!/bin/bash
read -p "please input your name:" -t 30 name
echo $name
read -p "please input your passwd:" -s passwd
echo -e "\n"
echo $passwd
read -p "please input your ***:" -n 1 ***
echo -e "\n"
echo $***
[root@catyuan ~]# /root/read.sh
please input your name:da
daplease input your passwd:
adfplease input your ***:1
1
shell接受鍵盤輸入引數
root localhost read 選項 變數名 選項 a 後跟乙個變數,該變數會被認為是個陣列,然後給其賦值,預設是以空格為分割符。p 提示資訊 在等待read輸入時,輸出提示資訊 t 秒數 read命令會一直等待使用者輸入,使用此選項可以指定等待時間 n 數字 read命令只接受指定的字元數...
shell程式設計之chown
語法 chown option owner group file chown option reference rfile file 描述 chown 改變指定檔案的使用者和 或組的擁有者。例如 liujl liujl rev 1 0 mycode test ls l 總用量 0 rw rw r 1...
shell 程式設計之echo
echo it is a test echo itis a testecho it is a test read 命令從標準輸入中讀取一行,並把輸入行的每個欄位的值指定給 shell 變數 bin sh read name echo name it is a test 以上 儲存為 test.sh,...