#!/bin/bash
# This is a Shell script to find the files created by Today
#
# Usage is:
#
# test.sh <dir>
#
function recurce()
{
cd $1 #进入该目录
for file in * ; #对目录中的每一个文件都逐一检查
do
if [ -d "$file" ]; then #如果该文件还是目录
recurce $file
fi
if [ -f "$file" ] ; then #如果文件是普通文件
longfile=`ls -l --time-style=long-iso $file` #获取文件的信息
check=`echo $longfile | grep $today`
if [ -n "$check" ] ; then #查看该文件的信息中的时间是不是今天
echo "$PWD/$file"
fi
fi
done
}
function main () #主函数,
{
today=`date +%Y-%m-%d` #获得当前的时间。
directory=$1
if [ -z "$directory" ];then #如果传入main函数的参数是一个空目录,则输入默认的目录
directory="."
fi
recurce $directory
}
main $1 #脚本入口
exit
Shell 脚本1 -- 查看今天更新/创建的文件
最新推荐文章于 2023-06-07 10:38:07 发布