How to recursively list all files with timestamps and full path?












3














I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this:



10:30 Dec 10 2010 /tmp/mydir/myfile


I've tried with:



find . -type f -exec ls -la {} ;


but that doesn't give me the full path.










share|improve this question





























    3














    I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this:



    10:30 Dec 10 2010 /tmp/mydir/myfile


    I've tried with:



    find . -type f -exec ls -la {} ;


    but that doesn't give me the full path.










    share|improve this question



























      3












      3








      3


      1





      I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this:



      10:30 Dec 10 2010 /tmp/mydir/myfile


      I've tried with:



      find . -type f -exec ls -la {} ;


      but that doesn't give me the full path.










      share|improve this question















      I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this:



      10:30 Dec 10 2010 /tmp/mydir/myfile


      I've tried with:



      find . -type f -exec ls -la {} ;


      but that doesn't give me the full path.







      linux ls






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 4 '14 at 20:16









      slhck

      159k47441464




      159k47441464










      asked Jan 3 '11 at 11:22









      user48777

      1981210




      1981210






















          4 Answers
          4






          active

          oldest

          votes


















          1














          And another way to do it if your find doesn't support printf



          find . -type f | xargs ls -al  | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'  


          Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:



          2010-09-29 22:08 /home/nifle/ac.txt
          2010-10-04 16:02 /home/nifle/array.sh
          2010-10-05 23:32 /home/nifle/b.txt
          2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
          2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
          2010-09-29 22:16 /home/nifle/foo.gz
          2010-09-29 22:16 /home/nifle/foo1.gz





          share|improve this answer



















          • 1




            As long as there aren't any spaces in the filenames.
            – Dennis Williamson
            Jan 3 '11 at 12:07










          • @Dennis - Ahh, yes you definitely have a point there.
            – Nifle
            Jan 3 '11 at 12:10



















          7














          Solution 1 (ls)



          Run ls on each file and filter the result:



          find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-


          Output:



          Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
          Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
          Jan 2 1972 /tmp/superuser.com/questions/228529/old_file


          Solution 2 (-printf)



          Use -printf:



          find "$PWD" -type f -printf "%t %pn"


          Output:



          Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
          Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
          Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file


          Solution 3 (stat)



          Run GNU stat on each file:



          find "$PWD" -type f -exec stat --format '%y %n' {} ;


          Output:



          2016-03-30 04:32:10.034718786 +0300 /etc/passwd
          2015-12-21 19:30:07.854470768 +0200 /etc/group




          Tip: if you have GNU find, ; can be replaced with +.






          share|improve this answer























          • You can replace $PWD with ..
            – Dennis Williamson
            Jan 3 '11 at 12:08










          • @Dennis Williamson: the command from the question already uses . instead of $PWD and it doesn't give him the full path.
            – Cristian Ciupitu
            Jan 3 '11 at 21:09










          • Ah, sorry, you are correct.
            – Dennis Williamson
            Jan 3 '11 at 21:23



















          0














          This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:



          find $ABSOLUTE_PATH_TO_DIR -ls





          share|improve this answer































            0














            tree is a nice alternative:



            tree -fD --timefmt %c



            Format the time using strftime syntax.






            share|improve this answer





















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              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',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f228529%2fhow-to-recursively-list-all-files-with-timestamps-and-full-path%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              And another way to do it if your find doesn't support printf



              find . -type f | xargs ls -al  | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'  


              Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:



              2010-09-29 22:08 /home/nifle/ac.txt
              2010-10-04 16:02 /home/nifle/array.sh
              2010-10-05 23:32 /home/nifle/b.txt
              2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
              2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
              2010-09-29 22:16 /home/nifle/foo.gz
              2010-09-29 22:16 /home/nifle/foo1.gz





              share|improve this answer



















              • 1




                As long as there aren't any spaces in the filenames.
                – Dennis Williamson
                Jan 3 '11 at 12:07










              • @Dennis - Ahh, yes you definitely have a point there.
                – Nifle
                Jan 3 '11 at 12:10
















              1














              And another way to do it if your find doesn't support printf



              find . -type f | xargs ls -al  | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'  


              Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:



              2010-09-29 22:08 /home/nifle/ac.txt
              2010-10-04 16:02 /home/nifle/array.sh
              2010-10-05 23:32 /home/nifle/b.txt
              2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
              2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
              2010-09-29 22:16 /home/nifle/foo.gz
              2010-09-29 22:16 /home/nifle/foo1.gz





              share|improve this answer



















              • 1




                As long as there aren't any spaces in the filenames.
                – Dennis Williamson
                Jan 3 '11 at 12:07










              • @Dennis - Ahh, yes you definitely have a point there.
                – Nifle
                Jan 3 '11 at 12:10














              1












              1








              1






              And another way to do it if your find doesn't support printf



              find . -type f | xargs ls -al  | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'  


              Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:



              2010-09-29 22:08 /home/nifle/ac.txt
              2010-10-04 16:02 /home/nifle/array.sh
              2010-10-05 23:32 /home/nifle/b.txt
              2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
              2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
              2010-09-29 22:16 /home/nifle/foo.gz
              2010-09-29 22:16 /home/nifle/foo1.gz





              share|improve this answer














              And another way to do it if your find doesn't support printf



              find . -type f | xargs ls -al  | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'  


              Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:



              2010-09-29 22:08 /home/nifle/ac.txt
              2010-10-04 16:02 /home/nifle/array.sh
              2010-10-05 23:32 /home/nifle/b.txt
              2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
              2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
              2010-09-29 22:16 /home/nifle/foo.gz
              2010-09-29 22:16 /home/nifle/foo1.gz






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jan 4 '14 at 20:16









              slhck

              159k47441464




              159k47441464










              answered Jan 3 '11 at 11:59









              Nifle

              27.9k2393128




              27.9k2393128








              • 1




                As long as there aren't any spaces in the filenames.
                – Dennis Williamson
                Jan 3 '11 at 12:07










              • @Dennis - Ahh, yes you definitely have a point there.
                – Nifle
                Jan 3 '11 at 12:10














              • 1




                As long as there aren't any spaces in the filenames.
                – Dennis Williamson
                Jan 3 '11 at 12:07










              • @Dennis - Ahh, yes you definitely have a point there.
                – Nifle
                Jan 3 '11 at 12:10








              1




              1




              As long as there aren't any spaces in the filenames.
              – Dennis Williamson
              Jan 3 '11 at 12:07




              As long as there aren't any spaces in the filenames.
              – Dennis Williamson
              Jan 3 '11 at 12:07












              @Dennis - Ahh, yes you definitely have a point there.
              – Nifle
              Jan 3 '11 at 12:10




              @Dennis - Ahh, yes you definitely have a point there.
              – Nifle
              Jan 3 '11 at 12:10













              7














              Solution 1 (ls)



              Run ls on each file and filter the result:



              find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-


              Output:



              Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
              Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
              Jan 2 1972 /tmp/superuser.com/questions/228529/old_file


              Solution 2 (-printf)



              Use -printf:



              find "$PWD" -type f -printf "%t %pn"


              Output:



              Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
              Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
              Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file


              Solution 3 (stat)



              Run GNU stat on each file:



              find "$PWD" -type f -exec stat --format '%y %n' {} ;


              Output:



              2016-03-30 04:32:10.034718786 +0300 /etc/passwd
              2015-12-21 19:30:07.854470768 +0200 /etc/group




              Tip: if you have GNU find, ; can be replaced with +.






              share|improve this answer























              • You can replace $PWD with ..
                – Dennis Williamson
                Jan 3 '11 at 12:08










              • @Dennis Williamson: the command from the question already uses . instead of $PWD and it doesn't give him the full path.
                – Cristian Ciupitu
                Jan 3 '11 at 21:09










              • Ah, sorry, you are correct.
                – Dennis Williamson
                Jan 3 '11 at 21:23
















              7














              Solution 1 (ls)



              Run ls on each file and filter the result:



              find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-


              Output:



              Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
              Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
              Jan 2 1972 /tmp/superuser.com/questions/228529/old_file


              Solution 2 (-printf)



              Use -printf:



              find "$PWD" -type f -printf "%t %pn"


              Output:



              Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
              Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
              Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file


              Solution 3 (stat)



              Run GNU stat on each file:



              find "$PWD" -type f -exec stat --format '%y %n' {} ;


              Output:



              2016-03-30 04:32:10.034718786 +0300 /etc/passwd
              2015-12-21 19:30:07.854470768 +0200 /etc/group




              Tip: if you have GNU find, ; can be replaced with +.






              share|improve this answer























              • You can replace $PWD with ..
                – Dennis Williamson
                Jan 3 '11 at 12:08










              • @Dennis Williamson: the command from the question already uses . instead of $PWD and it doesn't give him the full path.
                – Cristian Ciupitu
                Jan 3 '11 at 21:09










              • Ah, sorry, you are correct.
                – Dennis Williamson
                Jan 3 '11 at 21:23














              7












              7








              7






              Solution 1 (ls)



              Run ls on each file and filter the result:



              find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-


              Output:



              Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
              Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
              Jan 2 1972 /tmp/superuser.com/questions/228529/old_file


              Solution 2 (-printf)



              Use -printf:



              find "$PWD" -type f -printf "%t %pn"


              Output:



              Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
              Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
              Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file


              Solution 3 (stat)



              Run GNU stat on each file:



              find "$PWD" -type f -exec stat --format '%y %n' {} ;


              Output:



              2016-03-30 04:32:10.034718786 +0300 /etc/passwd
              2015-12-21 19:30:07.854470768 +0200 /etc/group




              Tip: if you have GNU find, ; can be replaced with +.






              share|improve this answer














              Solution 1 (ls)



              Run ls on each file and filter the result:



              find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-


              Output:



              Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
              Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
              Jan 2 1972 /tmp/superuser.com/questions/228529/old_file


              Solution 2 (-printf)



              Use -printf:



              find "$PWD" -type f -printf "%t %pn"


              Output:



              Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
              Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
              Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file


              Solution 3 (stat)



              Run GNU stat on each file:



              find "$PWD" -type f -exec stat --format '%y %n' {} ;


              Output:



              2016-03-30 04:32:10.034718786 +0300 /etc/passwd
              2015-12-21 19:30:07.854470768 +0200 /etc/group




              Tip: if you have GNU find, ; can be replaced with +.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Apr 7 '16 at 14:29

























              answered Jan 3 '11 at 11:37









              Cristian Ciupitu

              4,1192540




              4,1192540












              • You can replace $PWD with ..
                – Dennis Williamson
                Jan 3 '11 at 12:08










              • @Dennis Williamson: the command from the question already uses . instead of $PWD and it doesn't give him the full path.
                – Cristian Ciupitu
                Jan 3 '11 at 21:09










              • Ah, sorry, you are correct.
                – Dennis Williamson
                Jan 3 '11 at 21:23


















              • You can replace $PWD with ..
                – Dennis Williamson
                Jan 3 '11 at 12:08










              • @Dennis Williamson: the command from the question already uses . instead of $PWD and it doesn't give him the full path.
                – Cristian Ciupitu
                Jan 3 '11 at 21:09










              • Ah, sorry, you are correct.
                – Dennis Williamson
                Jan 3 '11 at 21:23
















              You can replace $PWD with ..
              – Dennis Williamson
              Jan 3 '11 at 12:08




              You can replace $PWD with ..
              – Dennis Williamson
              Jan 3 '11 at 12:08












              @Dennis Williamson: the command from the question already uses . instead of $PWD and it doesn't give him the full path.
              – Cristian Ciupitu
              Jan 3 '11 at 21:09




              @Dennis Williamson: the command from the question already uses . instead of $PWD and it doesn't give him the full path.
              – Cristian Ciupitu
              Jan 3 '11 at 21:09












              Ah, sorry, you are correct.
              – Dennis Williamson
              Jan 3 '11 at 21:23




              Ah, sorry, you are correct.
              – Dennis Williamson
              Jan 3 '11 at 21:23











              0














              This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:



              find $ABSOLUTE_PATH_TO_DIR -ls





              share|improve this answer




























                0














                This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:



                find $ABSOLUTE_PATH_TO_DIR -ls





                share|improve this answer


























                  0












                  0








                  0






                  This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:



                  find $ABSOLUTE_PATH_TO_DIR -ls





                  share|improve this answer














                  This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:



                  find $ABSOLUTE_PATH_TO_DIR -ls






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 23 '17 at 12:41









                  Community

                  1




                  1










                  answered Jan 3 '11 at 11:46









                  ayaz

                  6,93211525




                  6,93211525























                      0














                      tree is a nice alternative:



                      tree -fD --timefmt %c



                      Format the time using strftime syntax.






                      share|improve this answer


























                        0














                        tree is a nice alternative:



                        tree -fD --timefmt %c



                        Format the time using strftime syntax.






                        share|improve this answer
























                          0












                          0








                          0






                          tree is a nice alternative:



                          tree -fD --timefmt %c



                          Format the time using strftime syntax.






                          share|improve this answer












                          tree is a nice alternative:



                          tree -fD --timefmt %c



                          Format the time using strftime syntax.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 17 at 23:55









                          ManuelSchneid3r

                          383516




                          383516






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f228529%2fhow-to-recursively-list-all-files-with-timestamps-and-full-path%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Probability when a professor distributes a quiz and homework assignment to a class of n students.

                              Aardman Animations

                              Are they similar matrix