How do I find all the files that were created today in Unix/Linux?

后端 未结 11 559
梦谈多话
梦谈多话 2020-12-24 00:21

How do I find all the files that were create only today and not in 24 hour period in unix/linux

相关标签:
11条回答
  • 2020-12-24 00:51

    On my Fedora 10 system, with findutils-4.4.0-1.fc10.i386:

    find <path> -daystart -ctime 0 -print
    

    The -daystart flag tells it to calculate from the start of today instead of from 24 hours ago.

    Note however that this will actually list files created or modified in the last day. find has no options that look at the true creation date of the file.

    0 讨论(0)
  • 2020-12-24 00:54

    If you're did something like accidentally rsync'd to the wrong directory, the above suggestions work to find new files, but for me, the easiest was connecting with an SFTP client like Transmit then ordering by date and deleting.

    0 讨论(0)
  • 2020-12-24 00:56
    find . -mtime -1 -type f -print
    
    0 讨论(0)
  • 2020-12-24 00:56

    Just keep in mind there are 2 spaces between Aug and 26. Other wise your find command will not work.

    find . -type f -exec ls -l {} \; |  egrep "Aug 26";
    
    0 讨论(0)
  • 2020-12-24 00:57

    To find all files that are modified today only (since start of day only, i.e. 12 am), in current directory and its sub-directories:

    touch -t `date +%m%d0000` /tmp/$$
    find . -type f -newer /tmp/$$
    rm /tmp/$$
    

    Source

    0 讨论(0)
  • 2020-12-24 01:02

    After going through may posts i found the best one that really works

    find $file_path -type f -name "*.txt" -mtime -1 -printf "%f\n"
    

    This prints only the file name like abc.txt not the /path/tofolder/abc.txt

    Also also play around or customize with -mtime -1

    0 讨论(0)
提交回复
热议问题