log file before using rm command
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
add a comment |
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
add a comment |
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
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
14.04
edited 6 hours ago
Samuel P.
17010
17010
asked 16 hours ago
VenkiVenki
305
305
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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'
New contributor
add a comment |
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:
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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'
New contributor
add a comment |
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'
New contributor
add a comment |
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'
New contributor
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'
New contributor
New contributor
answered 15 hours ago
P. IakovakisP. Iakovakis
211
211
New contributor
New contributor
add a comment |
add a comment |
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:
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
add a comment |
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:
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
add a comment |
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:
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
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:
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
answered 6 hours ago
Samuel P.Samuel P.
17010
17010
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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