log file before using rm command












0















I am using rm -rf command to delete data from the folder.



Before deleting I want to know the file name and size that has been deleted from that folder and update in a log file. So that I can know which files are deleted from that folder.



I am using ubuntu 14.04. Is there any possible way?










share|improve this question





























    0















    I am using rm -rf command to delete data from the folder.



    Before deleting I want to know the file name and size that has been deleted from that folder and update in a log file. So that I can know which files are deleted from that folder.



    I am using ubuntu 14.04. Is there any possible way?










    share|improve this question



























      0












      0








      0


      0






      I am using rm -rf command to delete data from the folder.



      Before deleting I want to know the file name and size that has been deleted from that folder and update in a log file. So that I can know which files are deleted from that folder.



      I am using ubuntu 14.04. Is there any possible way?










      share|improve this question
















      I am using rm -rf command to delete data from the folder.



      Before deleting I want to know the file name and size that has been deleted from that folder and update in a log file. So that I can know which files are deleted from that folder.



      I am using ubuntu 14.04. Is there any possible way?







      14.04






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 6 hours ago









      Samuel P.

      17010




      17010










      asked 16 hours ago









      VenkiVenki

      305




      305






















          2 Answers
          2






          active

          oldest

          votes


















          2














          By using the -v argument you can see (log) everything that is being deleted.
          For more, like file size, you need to create a script that parses each directory and file, log the info you want and then delete them.



          temp (directory) 
          |- 1 (directory)
          |- 2 (directory)
          |-- 3.ge (file)



          user@laptop:~$ rm -rfv temp
          removed 'temp/1/2/3.ge'
          removed directory 'temp/1/2'
          removed directory 'temp/1'
          removed directory 'temp'






          share|improve this answer








          New contributor




          P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




























            0














            If you just want to know wich files where deleted you can use the -v option with rm, like P. Iakovakis already explained.



            If you want to simulate the deletion process and get a list which files are going to be deleted before executing the rm command you can use ls -shR with the delete parameter from rm:



            Folder structure:



            folder structure



            List files before deletion:



            $ ls -shR folder-to-delete
            folder-to-delete:
            total 20K
            4.0K folder 4.0K test 4.0K test1 4.0K test2 4.0K test3

            folder-to-delete/folder:
            total 8.0K
            4.0K test 4.0K test2


            Delete files and list them afterwards:



            $ rm -rfv folder-to-delete
            removed 'folder-to-delete/test'
            removed 'folder-to-delete/folder/test'
            removed 'folder-to-delete/folder/test2'
            removed directory 'folder-to-delete/folder'
            removed 'folder-to-delete/test2'
            removed 'folder-to-delete/test1'
            removed 'folder-to-delete/test3'
            removed directory 'folder-to-delete'


            Maybe you want to add the -l option to ls to get a list representation and more information of the files:



            $ ls -shRl folder-to-delete      
            folder-to-delete:
            total 20K
            4.0K drwxr-xr-x 2 root root 4.0K Mar 5 19:15 folder
            4.0K -rw-r--r-- 1 root root 5 Mar 5 19:15 test
            4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test1
            4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test2
            4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test3

            folder-to-delete/folder:
            total 8.0K
            4.0K -rw-r--r-- 1 root root 2 Mar 5 19:15 test
            4.0K -rw-r--r-- 1 root root 4 Mar 5 19:15 test2





            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              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%2faskubuntu.com%2fquestions%2f1123175%2flog-file-before-using-rm-command%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              By using the -v argument you can see (log) everything that is being deleted.
              For more, like file size, you need to create a script that parses each directory and file, log the info you want and then delete them.



              temp (directory) 
              |- 1 (directory)
              |- 2 (directory)
              |-- 3.ge (file)



              user@laptop:~$ rm -rfv temp
              removed 'temp/1/2/3.ge'
              removed directory 'temp/1/2'
              removed directory 'temp/1'
              removed directory 'temp'






              share|improve this answer








              New contributor




              P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

























                2














                By using the -v argument you can see (log) everything that is being deleted.
                For more, like file size, you need to create a script that parses each directory and file, log the info you want and then delete them.



                temp (directory) 
                |- 1 (directory)
                |- 2 (directory)
                |-- 3.ge (file)



                user@laptop:~$ rm -rfv temp
                removed 'temp/1/2/3.ge'
                removed directory 'temp/1/2'
                removed directory 'temp/1'
                removed directory 'temp'






                share|improve this answer








                New contributor




                P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.























                  2












                  2








                  2







                  By using the -v argument you can see (log) everything that is being deleted.
                  For more, like file size, you need to create a script that parses each directory and file, log the info you want and then delete them.



                  temp (directory) 
                  |- 1 (directory)
                  |- 2 (directory)
                  |-- 3.ge (file)



                  user@laptop:~$ rm -rfv temp
                  removed 'temp/1/2/3.ge'
                  removed directory 'temp/1/2'
                  removed directory 'temp/1'
                  removed directory 'temp'






                  share|improve this answer








                  New contributor




                  P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  By using the -v argument you can see (log) everything that is being deleted.
                  For more, like file size, you need to create a script that parses each directory and file, log the info you want and then delete them.



                  temp (directory) 
                  |- 1 (directory)
                  |- 2 (directory)
                  |-- 3.ge (file)



                  user@laptop:~$ rm -rfv temp
                  removed 'temp/1/2/3.ge'
                  removed directory 'temp/1/2'
                  removed directory 'temp/1'
                  removed directory 'temp'







                  share|improve this answer








                  New contributor




                  P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 15 hours ago









                  P. IakovakisP. Iakovakis

                  211




                  211




                  New contributor




                  P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  P. Iakovakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.

























                      0














                      If you just want to know wich files where deleted you can use the -v option with rm, like P. Iakovakis already explained.



                      If you want to simulate the deletion process and get a list which files are going to be deleted before executing the rm command you can use ls -shR with the delete parameter from rm:



                      Folder structure:



                      folder structure



                      List files before deletion:



                      $ ls -shR folder-to-delete
                      folder-to-delete:
                      total 20K
                      4.0K folder 4.0K test 4.0K test1 4.0K test2 4.0K test3

                      folder-to-delete/folder:
                      total 8.0K
                      4.0K test 4.0K test2


                      Delete files and list them afterwards:



                      $ rm -rfv folder-to-delete
                      removed 'folder-to-delete/test'
                      removed 'folder-to-delete/folder/test'
                      removed 'folder-to-delete/folder/test2'
                      removed directory 'folder-to-delete/folder'
                      removed 'folder-to-delete/test2'
                      removed 'folder-to-delete/test1'
                      removed 'folder-to-delete/test3'
                      removed directory 'folder-to-delete'


                      Maybe you want to add the -l option to ls to get a list representation and more information of the files:



                      $ ls -shRl folder-to-delete      
                      folder-to-delete:
                      total 20K
                      4.0K drwxr-xr-x 2 root root 4.0K Mar 5 19:15 folder
                      4.0K -rw-r--r-- 1 root root 5 Mar 5 19:15 test
                      4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test1
                      4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test2
                      4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test3

                      folder-to-delete/folder:
                      total 8.0K
                      4.0K -rw-r--r-- 1 root root 2 Mar 5 19:15 test
                      4.0K -rw-r--r-- 1 root root 4 Mar 5 19:15 test2





                      share|improve this answer




























                        0














                        If you just want to know wich files where deleted you can use the -v option with rm, like P. Iakovakis already explained.



                        If you want to simulate the deletion process and get a list which files are going to be deleted before executing the rm command you can use ls -shR with the delete parameter from rm:



                        Folder structure:



                        folder structure



                        List files before deletion:



                        $ ls -shR folder-to-delete
                        folder-to-delete:
                        total 20K
                        4.0K folder 4.0K test 4.0K test1 4.0K test2 4.0K test3

                        folder-to-delete/folder:
                        total 8.0K
                        4.0K test 4.0K test2


                        Delete files and list them afterwards:



                        $ rm -rfv folder-to-delete
                        removed 'folder-to-delete/test'
                        removed 'folder-to-delete/folder/test'
                        removed 'folder-to-delete/folder/test2'
                        removed directory 'folder-to-delete/folder'
                        removed 'folder-to-delete/test2'
                        removed 'folder-to-delete/test1'
                        removed 'folder-to-delete/test3'
                        removed directory 'folder-to-delete'


                        Maybe you want to add the -l option to ls to get a list representation and more information of the files:



                        $ ls -shRl folder-to-delete      
                        folder-to-delete:
                        total 20K
                        4.0K drwxr-xr-x 2 root root 4.0K Mar 5 19:15 folder
                        4.0K -rw-r--r-- 1 root root 5 Mar 5 19:15 test
                        4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test1
                        4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test2
                        4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test3

                        folder-to-delete/folder:
                        total 8.0K
                        4.0K -rw-r--r-- 1 root root 2 Mar 5 19:15 test
                        4.0K -rw-r--r-- 1 root root 4 Mar 5 19:15 test2





                        share|improve this answer


























                          0












                          0








                          0







                          If you just want to know wich files where deleted you can use the -v option with rm, like P. Iakovakis already explained.



                          If you want to simulate the deletion process and get a list which files are going to be deleted before executing the rm command you can use ls -shR with the delete parameter from rm:



                          Folder structure:



                          folder structure



                          List files before deletion:



                          $ ls -shR folder-to-delete
                          folder-to-delete:
                          total 20K
                          4.0K folder 4.0K test 4.0K test1 4.0K test2 4.0K test3

                          folder-to-delete/folder:
                          total 8.0K
                          4.0K test 4.0K test2


                          Delete files and list them afterwards:



                          $ rm -rfv folder-to-delete
                          removed 'folder-to-delete/test'
                          removed 'folder-to-delete/folder/test'
                          removed 'folder-to-delete/folder/test2'
                          removed directory 'folder-to-delete/folder'
                          removed 'folder-to-delete/test2'
                          removed 'folder-to-delete/test1'
                          removed 'folder-to-delete/test3'
                          removed directory 'folder-to-delete'


                          Maybe you want to add the -l option to ls to get a list representation and more information of the files:



                          $ ls -shRl folder-to-delete      
                          folder-to-delete:
                          total 20K
                          4.0K drwxr-xr-x 2 root root 4.0K Mar 5 19:15 folder
                          4.0K -rw-r--r-- 1 root root 5 Mar 5 19:15 test
                          4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test1
                          4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test2
                          4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test3

                          folder-to-delete/folder:
                          total 8.0K
                          4.0K -rw-r--r-- 1 root root 2 Mar 5 19:15 test
                          4.0K -rw-r--r-- 1 root root 4 Mar 5 19:15 test2





                          share|improve this answer













                          If you just want to know wich files where deleted you can use the -v option with rm, like P. Iakovakis already explained.



                          If you want to simulate the deletion process and get a list which files are going to be deleted before executing the rm command you can use ls -shR with the delete parameter from rm:



                          Folder structure:



                          folder structure



                          List files before deletion:



                          $ ls -shR folder-to-delete
                          folder-to-delete:
                          total 20K
                          4.0K folder 4.0K test 4.0K test1 4.0K test2 4.0K test3

                          folder-to-delete/folder:
                          total 8.0K
                          4.0K test 4.0K test2


                          Delete files and list them afterwards:



                          $ rm -rfv folder-to-delete
                          removed 'folder-to-delete/test'
                          removed 'folder-to-delete/folder/test'
                          removed 'folder-to-delete/folder/test2'
                          removed directory 'folder-to-delete/folder'
                          removed 'folder-to-delete/test2'
                          removed 'folder-to-delete/test1'
                          removed 'folder-to-delete/test3'
                          removed directory 'folder-to-delete'


                          Maybe you want to add the -l option to ls to get a list representation and more information of the files:



                          $ ls -shRl folder-to-delete      
                          folder-to-delete:
                          total 20K
                          4.0K drwxr-xr-x 2 root root 4.0K Mar 5 19:15 folder
                          4.0K -rw-r--r-- 1 root root 5 Mar 5 19:15 test
                          4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test1
                          4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test2
                          4.0K -rw-r--r-- 1 root root 6 Mar 5 19:15 test3

                          folder-to-delete/folder:
                          total 8.0K
                          4.0K -rw-r--r-- 1 root root 2 Mar 5 19:15 test
                          4.0K -rw-r--r-- 1 root root 4 Mar 5 19:15 test2






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 6 hours ago









                          Samuel P.Samuel P.

                          17010




                          17010






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Ask Ubuntu!


                              • 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%2faskubuntu.com%2fquestions%2f1123175%2flog-file-before-using-rm-command%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

                              數位音樂下載

                              格利澤436b

                              When can things happen in Etherscan, such as the picture below?