How can I sort find output by printing the most 10 latest update files?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












on my linux machines I want to know which file/s are edited recently by users



let say I want to search recursive under /home the most 10 files that edited recently



how to perform that with find command or other solution?



example of expected output:



27/6/2018 11:23 /home/my_data/file
27/6/2018 10:21 /home/top/oo/pp/file
27/6/2018 09:23 /home/my_data/GG/file






share|improve this question











migrated from serverfault.com Jul 5 at 9:01


This question came from our site for system and network administrators.










  • 1




    ls -lrt will list in date order use man ls to look at ls options.
    – Essex Boy
    Jun 27 at 12:55










  • yes but I want to search recursive
    – shalom
    Jun 27 at 13:08










  • find with -mtime
    – dmourati
    Jul 5 at 3:16














up vote
0
down vote

favorite












on my linux machines I want to know which file/s are edited recently by users



let say I want to search recursive under /home the most 10 files that edited recently



how to perform that with find command or other solution?



example of expected output:



27/6/2018 11:23 /home/my_data/file
27/6/2018 10:21 /home/top/oo/pp/file
27/6/2018 09:23 /home/my_data/GG/file






share|improve this question











migrated from serverfault.com Jul 5 at 9:01


This question came from our site for system and network administrators.










  • 1




    ls -lrt will list in date order use man ls to look at ls options.
    – Essex Boy
    Jun 27 at 12:55










  • yes but I want to search recursive
    – shalom
    Jun 27 at 13:08










  • find with -mtime
    – dmourati
    Jul 5 at 3:16












up vote
0
down vote

favorite









up vote
0
down vote

favorite











on my linux machines I want to know which file/s are edited recently by users



let say I want to search recursive under /home the most 10 files that edited recently



how to perform that with find command or other solution?



example of expected output:



27/6/2018 11:23 /home/my_data/file
27/6/2018 10:21 /home/top/oo/pp/file
27/6/2018 09:23 /home/my_data/GG/file






share|improve this question











on my linux machines I want to know which file/s are edited recently by users



let say I want to search recursive under /home the most 10 files that edited recently



how to perform that with find command or other solution?



example of expected output:



27/6/2018 11:23 /home/my_data/file
27/6/2018 10:21 /home/top/oo/pp/file
27/6/2018 09:23 /home/my_data/GG/file








share|improve this question










share|improve this question




share|improve this question









asked Jun 27 at 11:42







shalom











migrated from serverfault.com Jul 5 at 9:01


This question came from our site for system and network administrators.






migrated from serverfault.com Jul 5 at 9:01


This question came from our site for system and network administrators.









  • 1




    ls -lrt will list in date order use man ls to look at ls options.
    – Essex Boy
    Jun 27 at 12:55










  • yes but I want to search recursive
    – shalom
    Jun 27 at 13:08










  • find with -mtime
    – dmourati
    Jul 5 at 3:16












  • 1




    ls -lrt will list in date order use man ls to look at ls options.
    – Essex Boy
    Jun 27 at 12:55










  • yes but I want to search recursive
    – shalom
    Jun 27 at 13:08










  • find with -mtime
    – dmourati
    Jul 5 at 3:16







1




1




ls -lrt will list in date order use man ls to look at ls options.
– Essex Boy
Jun 27 at 12:55




ls -lrt will list in date order use man ls to look at ls options.
– Essex Boy
Jun 27 at 12:55












yes but I want to search recursive
– shalom
Jun 27 at 13:08




yes but I want to search recursive
– shalom
Jun 27 at 13:08












find with -mtime
– dmourati
Jul 5 at 3:16




find with -mtime
– dmourati
Jul 5 at 3:16










2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










To list recursively do



ls -lRrt


If you want to find all the files and list them in date change order



ls -lrt `find . -type f`


There's probably 10,000 ways to do it.






share|improve this answer





















  • This won't scale if the find output generates so many filenames that you get "argument list too long". An xargs variant would help.
    – wurtel
    Jun 27 at 14:19

















up vote
2
down vote













Finding the newest 10 files under the current directory:



find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10


Optionally add | cut -f2 to strip the time information.



This uses to -printf option to find to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort. sort -r does reverse sorting to put the newest (i.e. "biggest") times at the beginning.



This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n but with to null-terminate the filenames. Then add --zero-terminated to the sort options, and put | tr '' 'n' at the end to convert the null bytes back into newlines.






share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453557%2fhow-can-i-sort-find-output-by-printing-the-most-10-latest-update-files%23new-answer', 'question_page');

    );

    Post as a guest





























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    To list recursively do



    ls -lRrt


    If you want to find all the files and list them in date change order



    ls -lrt `find . -type f`


    There's probably 10,000 ways to do it.






    share|improve this answer





















    • This won't scale if the find output generates so many filenames that you get "argument list too long". An xargs variant would help.
      – wurtel
      Jun 27 at 14:19














    up vote
    2
    down vote



    accepted










    To list recursively do



    ls -lRrt


    If you want to find all the files and list them in date change order



    ls -lrt `find . -type f`


    There's probably 10,000 ways to do it.






    share|improve this answer





















    • This won't scale if the find output generates so many filenames that you get "argument list too long". An xargs variant would help.
      – wurtel
      Jun 27 at 14:19












    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    To list recursively do



    ls -lRrt


    If you want to find all the files and list them in date change order



    ls -lrt `find . -type f`


    There's probably 10,000 ways to do it.






    share|improve this answer













    To list recursively do



    ls -lRrt


    If you want to find all the files and list them in date change order



    ls -lrt `find . -type f`


    There's probably 10,000 ways to do it.







    share|improve this answer













    share|improve this answer



    share|improve this answer











    answered Jun 27 at 13:16









    Essex Boy

    1363




    1363











    • This won't scale if the find output generates so many filenames that you get "argument list too long". An xargs variant would help.
      – wurtel
      Jun 27 at 14:19
















    • This won't scale if the find output generates so many filenames that you get "argument list too long". An xargs variant would help.
      – wurtel
      Jun 27 at 14:19















    This won't scale if the find output generates so many filenames that you get "argument list too long". An xargs variant would help.
    – wurtel
    Jun 27 at 14:19




    This won't scale if the find output generates so many filenames that you get "argument list too long". An xargs variant would help.
    – wurtel
    Jun 27 at 14:19












    up vote
    2
    down vote













    Finding the newest 10 files under the current directory:



    find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10


    Optionally add | cut -f2 to strip the time information.



    This uses to -printf option to find to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort. sort -r does reverse sorting to put the newest (i.e. "biggest") times at the beginning.



    This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n but with to null-terminate the filenames. Then add --zero-terminated to the sort options, and put | tr '' 'n' at the end to convert the null bytes back into newlines.






    share|improve this answer

























      up vote
      2
      down vote













      Finding the newest 10 files under the current directory:



      find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10


      Optionally add | cut -f2 to strip the time information.



      This uses to -printf option to find to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort. sort -r does reverse sorting to put the newest (i.e. "biggest") times at the beginning.



      This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n but with to null-terminate the filenames. Then add --zero-terminated to the sort options, and put | tr '' 'n' at the end to convert the null bytes back into newlines.






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        Finding the newest 10 files under the current directory:



        find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10


        Optionally add | cut -f2 to strip the time information.



        This uses to -printf option to find to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort. sort -r does reverse sorting to put the newest (i.e. "biggest") times at the beginning.



        This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n but with to null-terminate the filenames. Then add --zero-terminated to the sort options, and put | tr '' 'n' at the end to convert the null bytes back into newlines.






        share|improve this answer













        Finding the newest 10 files under the current directory:



        find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10


        Optionally add | cut -f2 to strip the time information.



        This uses to -printf option to find to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort. sort -r does reverse sorting to put the newest (i.e. "biggest") times at the beginning.



        This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n but with to null-terminate the filenames. Then add --zero-terminated to the sort options, and put | tr '' 'n' at the end to convert the null bytes back into newlines.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jun 27 at 14:30









        wurtel

        8,6101822




        8,6101822






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453557%2fhow-can-i-sort-find-output-by-printing-the-most-10-latest-update-files%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?