From: moonhkt on
Hi All

Any suggestion ? Currently, I am using below shell command

cd delete_path
rm -f * # remove current directory files
rm -f */* # remove subdirectory files
rm -f */*/* # repeat ...
rm -f */*/*/*
rm -f */*/*/*/*
rm -f */*/*/*/*/*
rm -f */*/*/*/*/*/*
rm -f */*/*/*/*/*/*/*
rm -f */*/*/*/*/*/*/*/*
du -k | awk '{print $2}' |sort -r |xargs rmdir -p # remove all
subdirectory

moonhkt
From: Janis Papanagnou on
moonhkt wrote:
> Hi All
>
> Any suggestion ? Currently, I am using below shell command

rm(1) has options -r/-R to remove all subdiretories/files. See man rm
for details.

Other solutions to delete specific files are find(1) with option -exec
and a remove command or find(2) with -print0 and xargs -O. See man find
for details, or browse this group's archives since this is a frequent
question.

Janis

>
> cd delete_path
> rm -f * # remove current directory files
> rm -f */* # remove subdirectory files
> rm -f */*/* # repeat ...
> rm -f */*/*/*
> rm -f */*/*/*/*
> rm -f */*/*/*/*/*
> rm -f */*/*/*/*/*/*
> rm -f */*/*/*/*/*/*/*
> rm -f */*/*/*/*/*/*/*/*
> du -k | awk '{print $2}' |sort -r |xargs rmdir -p # remove all
> subdirectory
>
> moonhkt
From: Dominic Fandrey on
On 09/03/2010 08:06, moonhkt wrote:
> Hi All
>
> Any suggestion ? Currently, I am using below shell command
>
> cd delete_path
> rm -f * # remove current directory files
> rm -f */* # remove subdirectory files
> rm -f */*/* # repeat ...

What you are looking for is the both dangerous and popular drug
rm -rf *

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: jellybean stonerfish on
On Mon, 08 Mar 2010 23:06:54 -0800, moonhkt wrote:

> Hi All
>
> Any suggestion ? Currently, I am using below shell command
>
> cd delete_path
> rm -f * # remove current directory files rm -f */* # remove
> subdirectory files rm -f */*/* # repeat ... rm -f */*/*/*
> rm -f */*/*/*/*
> rm -f */*/*/*/*/*
> rm -f */*/*/*/*/*/*
> rm -f */*/*/*/*/*/*/*
> rm -f */*/*/*/*/*/*/*/*
> du -k | awk '{print $2}' |sort -r |xargs rmdir -p # remove all
> subdirectory
>
> moonhkt

Wow, that was a lot of work to replace 'rm -rf'

From: Ed Morton on
On 3/9/2010 1:06 AM, moonhkt wrote:
> Hi All
>
> Any suggestion ? Currently, I am using below shell command
>
> cd delete_path
> rm -f * # remove current directory files
> rm -f */* # remove subdirectory files
> rm -f */*/* # repeat ...
> rm -f */*/*/*
> rm -f */*/*/*/*
> rm -f */*/*/*/*/*
> rm -f */*/*/*/*/*/*
> rm -f */*/*/*/*/*/*/*
> rm -f */*/*/*/*/*/*/*/*
> du -k | awk '{print $2}' |sort -r |xargs rmdir -p # remove all
> subdirectory
>
> moonhkt

Genuinely curious - "rm" only has about 5 or 6 options so when you looked up the
man page did you not understand what "recursively" meant or not notice it or was
it something else?

Ed.