尝试使用导致错误的shell脚本

时间:2015-03-26 16:53:05

标签: shell grep cut

echo “enter the login of the user” 

read name

logindetails=`who|grep –w “$name” | grep “tty” `

if [ $? –ne 0 ]
then
    echo “$name has not logged in yet”
    exit
fi

loginhours=`echo “$logindetails” | cut –c 26,27`
loginminuts=`echo “$logindetails” | cut –c 29-30` 

hoursnow=`date | cut –c 12,13`
minnow=`date | cut –c 15,16` 

hour=`expr $loginhours - $hoursnow`
min=`expr $loginminuts - $minnow`

echo “ $name is working since $hour Hrs - $min Minuts”

一个shell脚本,用于确定指定用户在系统上工作的时间段。

0 个答案:

没有答案