文章出處
文章列表
有時會需要腳本用戶進行輸入,但不希望輸入的數據顯示在監視器上,典型的例子就是輸入密碼,當然還有很多其它類型的數據需要隱藏。
-s選項就能夠使read命令中輸入的數據不現實在監視器上(實際上,數據是顯示的,知識read命令將文本顏色設置成了與背景相同的顏色).
文件名: test26.sh
#!/bin/bash # hiding input data from the monitor read -s -p "Enter your passwd:" pass echo echo "Is your password really $pass?"
運行 sh test27.sh
輸出為: Enter your passwd:
這時你的輸入是不會顯示的,隨便輸入mylife,后,顯示為: Is your password really mylife?
文章列表
全站熱搜