linux文件操作记录,附查询历史操作记录文件shell

本shell是配合前一个记录用户历史操作记录shell的,代码如下:

#!/bin/sh -

# filename getrecord

user=

time=

while [ $# -gt 0 ]

do

case $1 in

-u|--user) user=$2

shift 2

;;

-t|--time) time=$2

shift 2

;;

-*)        echo "$0:$1 Wrong Options!" >&2

shift

exit 0

;;

--)        break

;;

*)         break

;;

esac

done

if [ -z "$user" ]

then

user=${LOGNAME}

fi

if [ -z "$time" ]

then

time=`date +%Y%m%d`

fi

file=`find /tmp/operation/$user/ |awk '/'$time'$/'`

cat $file

此段shell通过接收用户及时间参数来查看某用户的历史操作记录,如:

# getrecord -u root -t 20101223     --查看root在12月23号对服务器做的记录

如果不给定参数,shell将提取当前登陆用户及当日时间来进行查询.

你可以将此shell添加到bin中,直接使用命令来查询:

# mv getrecord ~/bin

# getrecord0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值