vi test.sh
貼上以下內容
mounth=`awk '/new user:/{print $1,$2,$8}' /var/log/secure* | grep "\<$USER\>"| cut -d " " -f1`
day=`awk '/new user:/{print $1,$2,$8}' /var/log/secure* | grep "\<$USER\>"| cut -d " " -f2`
ktdate=`date -d "$mounth $day" +%Y-%m-%d`
echo $ktdate
day=`awk '/new user:/{print $1,$2,$8}' /var/log/secure* | grep "\<$USER\>"| cut -d " " -f2`
ktdate=`date -d "$mounth $day" +%Y-%m-%d`
echo $ktdate
存檔後離開,執行它
[root@localhost tmp]# ./test
2013-03-10
2013-03-10