Shell Script 1--View today's updated/created files

Source: Internet
Author: User
#!/bin/bash
# This are a Shell script to find the files created by today
#
# Usage are:
#
#    test.sh <dir>
#

function Recurce ()
{
    CD is             #进入该目录 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 ()        # The main function,
{
    today= ' date +%y-%m-%d '        #获得当前的时间.
    directory=$1
    If [-Z "$directory"];then        #如果传入main函数的参数是一个空目录, enter the default directory
        directory= "."
    Fi
    recurce $directory
}

main $            #脚本入口

exit



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.