首页 > 技术文章 > shell 一些例子

shiyiwen 2015-11-27 09:47 原文

#!/bin/bash
#Filename: password.sh   by:-V love cmx

stty -echo                                                     #这里表示 开启隐藏在终端的输出
read -p "Enter your password: " input               #中间需要输入的任何信息都不会被打印出来,当 
stty echo                                                      #关闭隐藏功能
echo
echo "Password read is $input"    


这个时候只是交互的时候,用户输入的东西隐藏。但是 该显示的还是会显示,比如上个例子中的Enter your password!当然read 还自己带了一个选项来不回显这个输入的密码。

 

 

#!/bin/bash
# by -v love cmx

start=`date +%s`
while read line
do

    echo $line
done < 2.txt

end=`date +%s`

difftime=$((end-start))
echo this running time is $difftime senconds

 seq 1 100000 > 2.txt

10万个数字while 读取 一共8秒。多少毫秒还不知道咯,

推荐阅读