Linux 尋找日期為某一天的檔案

來源:互聯網
上載者:User
 

尋找日期為某一天的檔案

技巧管理員(2000-12-22 23:24)

〖返回〗〖轉寄〗

A=`find ~ -print` | ls -l --full-time $A 2>/dev/null | grep "Jun 27" | grep 1998 
    Linux的命令很厲害的呀! 
    給你寫了下面這個script,用著方便點兒。你把它存成一個隨便什麼名字的檔案,置上x屬性就行了。 
        #!/bin/sh 
        # The right of usage, distribution and modification is here by granted by the author. 
        # The author deny any responsibilities and liabilities related to the code. 
        # 
        OK=0 
        A=`find $1 -print` 
        if expr $3 == 1 >/dev/null ; then M=Jan ; OK=1 ; fi 
        if expr $3 == 2 >/dev/null ; then M=Feb ; OK=1 ; fi 
        if expr $3 == 3 >/dev/null ; then M=Mar ; OK=1 ; fi 
        if expr $3 == 4 >/dev/null ; then M=Apr ; OK=1 ; fi 
        if expr $3 == 5 >/dev/null ; then M=May ; OK=1 ; fi 
        if expr $3 == 6 >/dev/null ; then M=Jun ; OK=1 ; fi 
        if expr $3 == 7 >/dev/null ; then M=Jul ; OK=1 ; fi 
        if expr $3 == 8 >/dev/null ; then M=Aug ; OK=1 ; fi 
        if expr $3 == 9 >/dev/null ; then M=Sep ; OK=1 ; fi 
        if expr $3 == 10 >/dev/null ; then M=Oct ; OK=1 ; fi 
        if expr $3 == 11 >/dev/null ; then M=Nov ; OK=1 ; fi 
        if expr $3 == 12 >/dev/null ; then M=Dec ; OK=1 ; fi 
        if expr $3 == 1 >/dev/null ; then M=Jan ; OK=1 ; fi 
        if expr $OK == 1 > /dev/null ; then 
        ls -l --full-time $A 2>/dev/null | grep "$M $4" | grep $2 ; 
        else 
            echo Usage: $0 path Year Month Day; 
            echo Example: $0 ~ 1998 6 30; 
        fi
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.