Recursively delete only dirnames ending with "_files"
Linux - NewbieThis forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
DESCRIPTION
This manual page documents the GNU version of rm. rm removes each specified file. By default, it does not remove directories. If a file is unwritable, the standard input is a tty, and the -f or --force option is not given, rm prompts the user for whether to remove the file. If the response does not begin with `y' or `Y', the file is skipped.
OPTIONS
Remove (unlink) the FILE(s).
-d, --directory
unlink FILE, even if it is a non-empty directory (super-user only; this works only if your system
supports `unlink' for nonempty directories)
-f, --force
ignore nonexistent files, never prompt
-i, --interactive
prompt before any removal
--no-preserve-root do not treat `/' specially (the default)
--preserve-root
fail to operate recursively on `/'
-r, -R, --recursive
remove the contents of directories recursively
-v, --verbose
explain what is being done
--help
display this help and exit
--version
output version information and exit
To remove a file whose name starts with a `-', for example `-foo', use one of these commands:
rm -- -foo
rm ./-foo
Note that if you use rm to remove a file, it is usually possible to recover the contents of that file. If you want more assurance that the contents are truly unrecoverable, consider using shred.
Be very careful when using the 'rm' and options as you could screw your system up.
thanks for the good wishes, but why were you assuming I had not read the rm manual? And if you think I need to learn how to ask questions "the Smart Way", why don't you point out what you consider lacking in my post?
Really, I find your reply to be most unhelpful.
Here is the entire "man rm" file on my (Arch) system:
"RM(1) User Commands RM(1)
NAME
rm - remove files or directories
SYNOPSIS
rm [OPTION]... FILE...
DESCRIPTION
This manual page documents the GNU version of rm. rm removes each specified file. By default, it does
not remove directories.
If the -I or --interactive=once option is given, and there are more than three files or the -r, -R, or
--recursive are given, then rm prompts the user for whether to proceed with the entire operation. If
the response is not affirmative, the entire command is aborted.
Otherwise, if a file is unwritable, standard input is a terminal, and the -f or --force option is not
given, or the -i or --interactive=always option is given, rm prompts the user for whether to remove the
file. If the response is not affirmative, the file is skipped.
OPTIONS
Remove (unlink) the FILE(s).
-f, --force
ignore nonexistent files, never prompt
-i prompt before every removal
-I prompt once before removing more than three files, or when removing recursively. Less intrusive
than -i, while still giving protection against most mistakes
--interactive[=WHEN]
prompt according to WHEN: never, once (-I), or always (-i). Without WHEN, prompt always
--one-file-system
when removing a hierarchy recursively, skip any directory that is on a file system different
from that of the corresponding command line argument
--no-preserve-root
do not treat `/' specially
--preserve-root
do not remove `/' (default)
-r, -R, --recursive
remove directories and their contents recursively
-v, --verbose
explain what is being done
--help display this help and exit
--version
output version information and exit
By default, rm does not remove directories. Use the --recursive (-r or -R) option to remove each
listed directory, too, along with all of its contents.
To remove a file whose name starts with a `-', for example `-foo', use one of these commands:
rm -- -foo
rm ./-foo
Note that if you use rm to remove a file, it is usually possible to recover the contents of that file.
If you want more assurance that the contents are truly unrecoverable, consider using shred.
AUTHOR
Written by Paul Rubin, David MacKenzie, Richard M. Stallman, and Jim Meyering.
REPORTING BUGS
Report rm bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
You did try the '-d' option as root? We all present things in a manner that is not always complete. I assumed since you were using the 'rm' recursively then you may have over looked the '-d' option since nothing seemed important below a certain point.
I thought the original post was about recursively removing the directories that ended with _files from the current directory. I posted basically what the OP said he already tried.
Last edited by joeBuffer; 08-17-2009 at 10:43 AM..
My bad on the '-d'. It is not longer supported with 'rm'.
I'm used to explicit remove with the '-r' and '-f' to force but do remember the '-d'. I also remember that the unlinking with the '-d' could cause some problems. So the 'rm -rf somefiles' would be better use. But as root you had better be certain of the use.
You might want to look at 'shred' if you are a little paranoid about the files.
I'll have to note to the author about the need to remove the '-d' from the online reference.
I've never had a problem using "rm -rf" to remove full directory hierarchies, use with caution, it's like nuclear fission, once it starts it's very difficult to stop the chain reaction s
it's like nuclear fission, once it starts it's very difficult to stop the chain reaction s
He he... you're right! After eleven years using *nix, last month I accidentally "removed minus ar" an entire directory tree: 300 Gb before my time of reaction let me press Ctrl-C!
He he... you're right! After eleven years using *nix, last month I accidentally "removed minus ar" an entire directory tree: 300 Gb before my time of reaction let me press Ctrl-C!
Yeah -- I did it once cleaning up a mission-critical user-acceptance/bugfix system because I scripted rm -rf after a cd and forgot to error trap the cd. No problem -- what are backups for? Reinstall and restore. Routine stuff. But DVDs were new then and there was no way to mount both / and /usr with the DVD drive in place and the only way to install the OS was from DVD. Ouch! A long night and a tired dawn but the users only lost a couple of hours work.
"My bad" is appearing more often. I'd assumed it came from automated translation but that's not the case here. Has automated translation produced a new usage? I love how human languages evolve and how, doing so, they encapsulate human history.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.