Some Questions About Deleting Files
I know that rm -i will prompt wether you want to delete each file.
But rm -i -r will prompt for each file in each subdirectory recursively. How to make it prompt just for the directory itself, and then delete its contents without asking? How to delete all the files in a directory without deleting . and ..? How to recursively delete all tilde files in a directory? How to GUI file managers delete files to Trash? Where is this "Trash" located? Can you delete to trash in the command line? |
> How to make it prompt just for the directory itself, and then delete its contents without asking?
There may be an easier way, but this is what came to me first: Code:
for i in `find . -type d`; do > How to delete all the files in a directory without deleting . and ..? find . -type f -maxdepth 1 | xargs rm -f > How to recursively delete all tilde files in a directory? find . -type f -name '~*' | xargs rm -f GUI file managers 'delete to trash' is a move to a specific folder designated as trash. |
Hm..
Quote:
Quote:
Quote:
|
Quote:
How would that prevent . and .. from being deleted? |
Hm. Let me ask you this: what command are you afraid of running, out of fear of removing "." and ".."?
|
I'm not in need of running a command that I'm afraid of. I'm just curious to know.
|
Know -what-? You said you don't know how to prevent "." and ".." being deleted. Don't delete them? What do you want us to say? My guess is that by looking at a directory listing:
Code:
$ ls -a video/ Code:
$ rm -rf video |
What will happen if I do this:
rm -rf .. And why does sudo rm -rf * delete everything, not just the contents of the current dir? |
Quote:
|
Quote:
Code:
$ mkdir one |
Quote:
|
No, but be careful. You will not be able to do a 'cd ..' afterwards, you'll have to change directory via absolute path.
|
Quote:
Anyway, here's what happens on my system: Code:
$ mkdir one |
Quote:
|
I'm so confused :confused:
Howcome rm -rf .. doesn't delete the parent but rm -rf * does? |
All times are GMT -5. The time now is 04:22 AM. |