• Re: shell command for deleting all subdirectories

    From The Natural Philosopher@21:1/5 to All on Sat Jul 5 13:28:47 2025
    On 05/07/2025 13:26, bilsch01 wrote:
    Hi. I am a windroid but I still have ubuntu partition with working Ubu
    22.04. I have Rhythmbox for music. I was slightly linux conversant years
    ago, but that's all gone now.
    I want to delete all subdirectories in ubuntu Music directory and then
    copy in the entire music collection from my Windows partition.

    MY QUESTION:
    what is linux shell command to delete all subdirectories in Music?
    TIA
    Bill S.
    cd ~/Music
    rm - r *

    --
    "Nature does not give up the winter because people dislike the cold."

    ― Confucius

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From bilsch01@21:1/5 to All on Sat Jul 5 05:26:34 2025
    Hi. I am a windroid but I still have ubuntu partition with working Ubu
    22.04. I have Rhythmbox for music. I was slightly linux conversant years
    ago, but that's all gone now.
    I want to delete all subdirectories in ubuntu Music directory and then
    copy in the entire music collection from my Windows partition.

    MY QUESTION:
    what is linux shell command to delete all subdirectories in Music?
    TIA
    Bill S.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bill Ubuntu@21:1/5 to The Natural Philosopher on Sat Jul 5 06:36:43 2025
    On 7/5/25 05:28, The Natural Philosopher wrote:
    On 05/07/2025 13:26, bilsch01 wrote:
    Hi. I am a windroid but I still have ubuntu partition with working Ubu
    22.04. I have Rhythmbox for music. I was slightly linux conversant
    years ago, but that's all gone now.
    I want to delete all subdirectories in ubuntu Music directory and then
    copy in the entire music collection from my Windows partition.

    MY QUESTION:
    what is linux shell command to delete all subdirectories in Music?
    TIA
    Bill S.
    cd ~/Music
    rm - r  *


    for each directory it says: cannot remove because that is a directory

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bill Ubuntu@21:1/5 to Charlie Gibbs on Sat Jul 5 06:45:22 2025
    On 7/5/25 06:36, Charlie Gibbs wrote:
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    cd ~/Music
    rm - r *

    Oops, an extra space slipped in there. The correct command is:

    rm -r *

    it worked good Thanks

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to Charlie Gibbs on Sat Jul 5 14:46:03 2025
    On 05/07/2025 14:36, Charlie Gibbs wrote:
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    cd ~/Music
    rm - r *

    Oops, an extra space slipped in there. The correct command is:

    rm -r *

    Ah...
    --
    “People believe certain stories because everyone important tells them,
    and people tell those stories because everyone important believes them.
    Indeed, when a conventional wisdom is at its fullest strength, one’s agreement with that conventional wisdom becomes almost a litmus test of
    one’s suitability to be taken seriously.”

    Paul Krugman

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to Bill Ubuntu on Sat Jul 5 14:50:25 2025
    On 05/07/2025 14:36, Bill Ubuntu wrote:
    On 7/5/25 05:28, The Natural Philosopher wrote:
    On 05/07/2025 13:26, bilsch01 wrote:
    Hi. I am a windroid but I still have ubuntu partition with working
    Ubu 22.04. I have Rhythmbox for music. I was slightly linux
    conversant years ago, but that's all gone now.
    I want to delete all subdirectories in ubuntu Music directory and
    then copy in the entire music collection from my Windows partition.

    MY QUESTION:
    what is linux shell command to delete all subdirectories in Music?
    TIA
    Bill S.
    cd ~/Music
    rm - r  *


    for each directory it says: cannot remove because that is a directory

    Try it without the error
    cd ~/Music
    rm -r *
    --
    “People believe certain stories because everyone important tells them,
    and people tell those stories because everyone important believes them.
    Indeed, when a conventional wisdom is at its fullest strength, one’s agreement with that conventional wisdom becomes almost a litmus test of
    one’s suitability to be taken seriously.”

    Paul Krugman

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Charlie Gibbs@21:1/5 to The Natural Philosopher on Sat Jul 5 13:36:18 2025
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    cd ~/Music
    rm - r *

    Oops, an extra space slipped in there. The correct command is:

    rm -r *

    --
    /~\ Charlie Gibbs | Growth for the sake of
    \ / <cgibbs@kltpzyxm.invalid> | growth is the ideology
    X I'm really at ac.dekanfrus | of the cancer cell.
    / \ if you read it the right way. | -- Edward Abbey

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jason H@21:1/5 to Bill Ubuntu on Sat Jul 5 17:00:54 2025
    On 05/07/2025 14:45, Bill Ubuntu wrote:
    On 7/5/25 06:36, Charlie Gibbs wrote:
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    cd ~/Music
    rm - r *

    Oops, an extra space slipped in there. The correct command is:

    rm -r *

    it worked good Thanks

    And be absolutely positively sure you are where you think you are (via pwd)
    when running that! I write from bitter experience.

    --
    --
    A PICKER OF UNCONSIDERED TRIFLES

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Carlos E.R.@21:1/5 to Jason H on Sat Jul 5 19:53:04 2025
    On 2025-07-05 19:00, Jason H wrote:
    On 05/07/2025 14:45, Bill Ubuntu wrote:
    On 7/5/25 06:36, Charlie Gibbs wrote:
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    cd ~/Music
    rm - r  *

    Oops, an extra space slipped in there.  The correct command is:

    rm -r *

     it worked good  Thanks

    And be absolutely positively sure you are where you think you are (via pwd) when running that! I write from bitter experience.

    Why not do

    rm -r ~/Music/*

    ?

    I think it is safer.

    --
    Cheers, Carlos.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rbowman@21:1/5 to Jason H on Sat Jul 5 18:12:57 2025
    On Sat, 5 Jul 2025 17:00:54 -0000 (UTC), Jason H wrote:

    On 05/07/2025 14:45, Bill Ubuntu wrote:
    On 7/5/25 06:36, Charlie Gibbs wrote:
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    cd ~/Music rm - r *

    Oops, an extra space slipped in there. The correct command is:

    rm -r *

    it worked good Thanks

    And be absolutely positively sure you are where you think you are (via
    pwd)
    when running that! I write from bitter experience.

    --

    We had a hapless programmer who tried to free up space on a AIX box by
    running the equivalent of 'rm -rf /usr/bin' . Partially in his defense the directory has a different name in AIX.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jason H@21:1/5 to Carlos E.R. on Sat Jul 5 21:48:55 2025
    On 05/07/2025 18:53, Carlos E.R. wrote:
    On 2025-07-05 19:00, Jason H wrote:
    On 05/07/2025 14:45, Bill Ubuntu wrote:
    On 7/5/25 06:36, Charlie Gibbs wrote:
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    cd ~/Music
    rm - r  *

    Oops, an extra space slipped in there.  The correct command is:

    rm -r *

     it worked good  Thanks

    And be absolutely positively sure you are where you think you are (via pwd) >> when running that! I write from bitter experience.

    Why not do

    rm -r ~/Music/*

    ?

    I think it is safer.

    Absolutely. If you know what ~ is.

    --
    A PICKER OF UNCONSIDERED TRIFLES

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Carlos E.R.@21:1/5 to Jason H on Sun Jul 6 01:29:34 2025
    On 2025-07-05 23:48, Jason H wrote:
    On 05/07/2025 18:53, Carlos E.R. wrote:
    On 2025-07-05 19:00, Jason H wrote:
    On 05/07/2025 14:45, Bill Ubuntu wrote:
    On 7/5/25 06:36, Charlie Gibbs wrote:
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music? >>>>>>
    cd ~/Music
    rm - r  *

    Oops, an extra space slipped in there.  The correct command is:

    rm -r *

     it worked good  Thanks

    And be absolutely positively sure you are where you think you are
    (via pwd)
    when running that! I write from bitter experience.

    Why not do

    rm -r ~/Music/*

    ?

    I think it is safer.

    Absolutely. If you know what ~ is.

    Not a problem. Same as for "cd ~/Music"



    --
    Cheers, Carlos.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuno Silva@21:1/5 to Lawrence D'Oliveiro on Sun Jul 6 03:09:38 2025
    On 2025-07-06, Lawrence D'Oliveiro wrote:

    On Sat, 5 Jul 2025 05:26:34 -0700, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    find Music -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf

    Should deal with all possibilities.

    Or alternatively, why not

    rm -rf Music && mkdir Music

    In this case, I suppose it really is better that way. You can't delete subdirectories without deleting the files. And if you delete the
    containing directory too along with all subdirectories, then there's
    indeed the ability to operate rm recursively on "Music".

    (Or were there *files* directly under ~/Music that were intended to be preserved?)

    --
    Nuno Silva

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Sun Jul 6 01:35:59 2025
    On Sat, 5 Jul 2025 05:26:34 -0700, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    find Music -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf

    Should deal with all possibilities.

    Or alternatively, why not

    rm -rf Music && mkdir Music

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Carlos E.R. on Sun Jul 6 01:33:47 2025
    On Sat, 5 Jul 2025 19:53:04 +0200, Carlos E.R. wrote:

    Why not do

    rm -r ~/Music/*

    ?

    If any file/dir names in there have spaces or even (shudder) newlines,
    then word-splitting may not produce the results you expect.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Nuno Silva on Sun Jul 6 03:13:08 2025
    On Sun, 06 Jul 2025 03:09:38 +0100, Nuno Silva wrote:

    (Or were there *files* directly under ~/Music that were intended to be preserved?)

    find Music -type d -empty -print0 | xargs -0 rmdir

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to Jason H on Sun Jul 6 09:05:40 2025
    On 05/07/2025 18:00, Jason H wrote:
    On 05/07/2025 14:45, Bill Ubuntu wrote:
    On 7/5/25 06:36, Charlie Gibbs wrote:
    On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 05/07/2025 13:26, bilsch01 wrote:

    what is linux shell command to delete all subdirectories in Music?

    cd ~/Music
    rm - r  *

    Oops, an extra space slipped in there.  The correct command is:

    rm -r *

     it worked good  Thanks

    And be absolutely positively sure you are where you think you are (via pwd) when running that! I write from bitter experience.

    Oh yes!

    --
    “Ideas are inherently conservative. They yield not to the attack of
    other ideas but to the massive onslaught of circumstance"

    - John K Galbraith

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Burns@21:1/5 to Carlos E.R. on Sun Jul 6 09:14:46 2025
    Carlos E.R. wrote:

    Jason H wrote:
    Carlos E.R. wrote:

    Why not do

    rm -r ~/Music/*

    ?

    I think it is safer.

    Absolutely. If you know what ~ is.

    Not a problem. Same as for "cd ~/Music"
    Be careful that news readers may display text with slashes and asterisks
    as italic and bold instead of displaying the actual slashes and
    asterisks ...

    e.g. it may display as

    rm -r ~𝑀𝑢𝑠𝑖𝑐*

    instead of the intended

    rm -r ~∕Music∕*

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Carlos E.R.@21:1/5 to Andy Burns on Sun Jul 6 15:31:21 2025
    On 2025-07-06 10:14, Andy Burns wrote:
    Carlos E.R. wrote:

    Jason H wrote:
    Carlos E.R. wrote:

    Why not do

    rm -r ~/Music/*

    ?

    I think it is safer.

    Absolutely. If you know what ~ is.

    Not a problem. Same as for "cd ~/Music"
    Be careful that news readers may display text with slashes and asterisks
    as italic and bold instead of displaying the actual slashes and
    asterisks ...

    e.g. it may display as

    rm -r ~𝑀𝑢𝑠𝑖𝑐*

    instead of the intended

    rm -r ~∕Music∕*

    Gosh, there is a cursive subset in UTF-8 :-o

    --
    Cheers, Carlos.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Carlos E.R.@21:1/5 to Lawrence D'Oliveiro on Sun Jul 6 15:33:27 2025
    On 2025-07-06 03:33, Lawrence D'Oliveiro wrote:
    On Sat, 5 Jul 2025 19:53:04 +0200, Carlos E.R. wrote:

    Why not do

    rm -r ~/Music/*

    ?

    If any file/dir names in there have spaces or even (shudder) newlines,
    then word-splitting may not produce the results you expect.

    Would that problem be different in:

    rm -r ~/Music/*

    compared to:

    cd ~/Music/*
    rm -r *


    --
    Cheers, Carlos.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuno Silva@21:1/5 to Carlos E.R. on Sun Jul 6 17:12:50 2025
    On 2025-07-06, Carlos E.R. wrote:

    On 2025-07-06 03:33, Lawrence D'Oliveiro wrote:
    On Sat, 5 Jul 2025 19:53:04 +0200, Carlos E.R. wrote:

    Why not do

    rm -r ~/Music/*

    ?

    If any file/dir names in there have spaces or even (shudder) newlines,
    then word-splitting may not produce the results you expect.

    Would that problem be different in:

    rm -r ~/Music/*

    compared to:

    cd ~/Music/*
    rm -r *

    I think so, yes. One problem is the same and present in both, word
    splitting will happen after the expansion of *.

    The second case has the added problem that the expanded elements have no prefix, so if they happen to match an option or a different valid
    argument to rm, they will be interpreted that way. If you're lucky,
    it'll be just invalid and you get a "file not found".

    If you're unlucky and on a non-GNU system, or old (how old?) GNU
    system, you may have files named, I don't know, something like

    "List of books / movies -fr 2024.pdf"

    then two things will happen for sure, one of the arguments is going to
    be -f, and another is going to be /. And -r is already there and the
    whole command becomes a giant "rm -rf /".

    (I just hope nobody ever writes a document with "--no-preserve-root" in
    the title, or it might end up in a filename somewhere...)



    (If someone reading this does not understand what is going on here, ask,
    don't try.)

    --
    Nuno Silva

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Carlos E.R. on Sun Jul 6 16:44:44 2025
    Carlos E.R. <robin_listas@es.invalid> wrote:
    On 2025-07-06 03:33, Lawrence D'Oliveiro wrote:
    On Sat, 5 Jul 2025 19:53:04 +0200, Carlos E.R. wrote:

    Why not do

    rm -r ~/Music/*

    ?

    If any file/dir names in there have spaces or even (shudder) newlines,
    then word-splitting may not produce the results you expect.

    Would that problem be different in:

    rm -r ~/Music/*

    compared to:

    cd ~/Music/*
    rm -r *

    No, because shell globbing for * directly passed to a command is not
    broken for oddball characters in names. What breaks is trying to use
    glob expansions in further shell expansions.

    i.e.:

    $ ls -l
    total 8
    drwxr-xr-x 2 users 4096 Jul 6 12:41 a\ directory\nwith\ newline/
    drwxr-xr-x 2 users 4096 Jul 6 12:39 a\ directory\ with\ spaces/
    -rw-r--r-- 1 users 0 Jul 6 12:41 a\ file\nwith\ newline
    -rw-r--r-- 1 users 0 Jul 6 12:38 a\ filename\ with\ spaces

    $ rm -r *
    $ ls -l
    total 0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuno Silva@21:1/5 to Rich on Sun Jul 6 18:20:33 2025
    On 2025-07-06, Rich wrote:

    Carlos E.R. <robin_listas@es.invalid> wrote:
    On 2025-07-06 03:33, Lawrence D'Oliveiro wrote:
    On Sat, 5 Jul 2025 19:53:04 +0200, Carlos E.R. wrote:

    Why not do

    rm -r ~/Music/*

    ?

    If any file/dir names in there have spaces or even (shudder) newlines,
    then word-splitting may not produce the results you expect.

    Would that problem be different in:

    rm -r ~/Music/*

    compared to:

    cd ~/Music/*
    rm -r *

    No, because shell globbing for * directly passed to a command is not
    broken for oddball characters in names. What breaks is trying to use
    glob expansions in further shell expansions.


    ... oh, right. Word splitting does not happen to the result of
    globbing. My mind was quite set in the scripting aspect of this and did
    not grasp this relevant fact.

    So the only issue would be the lack of prefix in the separate rm, and
    becomes much less likely to be an accidental issue (but quite easy to
    target if you're considering evil actors).


    --
    Nuno Silva

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Carlos E.R.@21:1/5 to Nuno Silva on Sun Jul 6 20:24:30 2025
    On 2025-07-06 18:12, Nuno Silva wrote:
    On 2025-07-06, Carlos E.R. wrote:

    On 2025-07-06 03:33, Lawrence D'Oliveiro wrote:
    On Sat, 5 Jul 2025 19:53:04 +0200, Carlos E.R. wrote:

    Why not do

    rm -r ~/Music/*

    ?

    If any file/dir names in there have spaces or even (shudder) newlines,
    then word-splitting may not produce the results you expect.

    Would that problem be different in:

    rm -r ~/Music/*

    compared to:

    cd ~/Music/*
    rm -r *

    I think so, yes. One problem is the same and present in both, word
    splitting will happen after the expansion of *.

    The second case has the added problem that the expanded elements have no prefix, so if they happen to match an option or a different valid
    argument to rm, they will be interpreted that way. If you're lucky,
    it'll be just invalid and you get a "file not found".

    If you're unlucky and on a non-GNU system, or old (how old?) GNU
    system, you may have files named, I don't know, something like

    "List of books / movies -fr 2024.pdf"

    then two things will happen for sure, one of the arguments is going to
    be -f, and another is going to be /. And -r is already there and the
    whole command becomes a giant "rm -rf /".

    Brrrr... :-(


    (I just hope nobody ever writes a document with "--no-preserve-root" in
    the title, or it might end up in a filename somewhere...)



    (If someone reading this does not understand what is going on here, ask, don't try.)



    --
    Cheers, Carlos.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to Nuno Silva on Sun Jul 6 19:56:17 2025
    Nuno Silva <nunojsilva@invalid.invalid> writes:
    On 2025-07-06, Carlos E.R. wrote:
    Would that problem be different in:

    rm -r ~/Music/*

    compared to:

    cd ~/Music/*
    rm -r *

    “cd ~/Music/*” will not work; you mean “cd ~/Music”.

    I think so, yes. One problem is the same and present in both, word
    splitting will happen after the expansion of *.

    No. Word splitting is first, then expansion. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_01

    The second case has the added problem that the expanded elements have no prefix, so if they happen to match an option or a different valid
    argument to rm, they will be interpreted that way. If you're lucky,
    it'll be just invalid and you get a "file not found".

    This one a real issue, with solutions turning up in Unix FAQs back at
    least to 1990 (probably longer). The completely portable solution is:

    rm -r ~/Music/*

    so that no expanded path starts ‘-’, or in anything vaguely modern:

    cd ~/Music
    rm -r -- *

    since ‘--’ prevents anything after it being interpreted as an option.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Fritz Wuehler@21:1/5 to All on Sun Jul 6 23:57:21 2025
    Lawrence D'Oliveiro <...@nz.invalid> [LD]:

    Why not do
    rm -r ~/Music/*

    If any file/dir names in there have spaces or even (shudder)
    newlines, then word-splitting may not produce the results you
    expect.

    The shell has no problem with such names:


    D=/tmp/test101; mkdir $D && mkdir $D/"a b" $D/"$(printf "a\nc")" && find $D echo deleting everything...
    rm -fr $D/* && find $D

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Fritz Wuehler on Sun Jul 6 23:15:35 2025
    On Sun, 06 Jul 2025 23:57:21 +0200, Fritz Wuehler wrote:

    If any file/dir names in there have spaces or even (shudder)
    newlines, then word-splitting may not produce the results you LD>
    expect.

    The shell has no problem with such names:

    Yeah, I forgot wildcard expansion happens *after* word-splitting ...
    normally ...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to Ralf Fassel on Mon Jul 7 09:59:57 2025
    On 07/07/2025 09:47, Ralf Fassel wrote:
    * The Natural Philosopher <tnp@invalid.invalid>
    | Try it without the error
    | cd ~/Music
    | rm -r *

    I'd rather do

    cd ~/Music && rm -r *

    If the 'cd' fails for any reason, you most definitely don't want
    the "rm -r *" to happen.

    R'
    Nice trick

    --
    If I had all the money I've spent on drink...
    ..I'd spend it on drink.

    Sir Henry (at Rawlinson's End)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Mon Jul 7 10:47:55 2025
    * The Natural Philosopher <tnp@invalid.invalid>
    | Try it without the error
    | cd ~/Music
    | rm -r *

    I'd rather do

    cd ~/Music && rm -r *

    If the 'cd' fails for any reason, you most definitely don't want
    the "rm -r *" to happen.

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Haber@21:1/5 to The Natural Philosopher on Mon Jul 7 13:32:49 2025
    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 07/07/2025 09:47, Ralf Fassel wrote:
    * The Natural Philosopher <tnp@invalid.invalid>
    | Try it without the error
    | cd ~/Music
    | rm -r *

    I'd rather do

    cd ~/Music && rm -r *

    If the 'cd' fails for any reason, you most definitely don't want
    the "rm -r *" to happen.

    R'
    Nice trick

    rm -r ~/Music would have been too easy?

    Greetings
    Marc
    --
    ---------------------------------------------------------------------------- Marc Haber | " Questions are the | Mailadresse im Header Rhein-Neckar, DE | Beginning of Wisdom " |
    Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fon: *49 6224 1600402

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to Marc Haber on Mon Jul 7 15:00:05 2025
    On 07/07/2025 12:32, Marc Haber wrote:
    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 07/07/2025 09:47, Ralf Fassel wrote:
    * The Natural Philosopher <tnp@invalid.invalid>
    | Try it without the error
    | cd ~/Music
    | rm -r *

    I'd rather do

    cd ~/Music && rm -r *

    If the 'cd' fails for any reason, you most definitely don't want
    the "rm -r *" to happen.

    R'
    Nice trick

    rm -r ~/Music would have been too easy?

    TBH whenever I use rm -r I double check to see if I am in the right
    directory FIRST

    rm -r ~/Music will remove the Music directory as well..

    Greetings
    Marc

    --
    No Apple devices were knowingly used in the preparation of this post.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From The Natural Philosopher@21:1/5 to Marc Haber on Mon Jul 7 16:05:21 2025
    On 07/07/2025 15:36, Marc Haber wrote:
    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 07/07/2025 12:32, Marc Haber wrote:
    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 07/07/2025 09:47, Ralf Fassel wrote:
    * The Natural Philosopher <tnp@invalid.invalid>
    | Try it without the error
    | cd ~/Music
    | rm -r *

    I'd rather do

    cd ~/Music && rm -r *

    If the 'cd' fails for any reason, you most definitely don't want
    the "rm -r *" to happen.

    R'
    Nice trick

    rm -r ~/Music would have been too easy?

    TBH whenever I use rm -r I double check to see if I am in the right
    directory FIRST

    rm -r ~/Music will remove the Music directory as well..

    You don't need to be a rocket scientist to come up with rm -f
    ~/Music/*

    That is what I originally said.

    But you changed it.

    Greetings
    Marc

    --
    "A point of view can be a dangerous luxury when substituted for insight
    and understanding".

    Marshall McLuhan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Haber@21:1/5 to The Natural Philosopher on Mon Jul 7 16:36:05 2025
    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 07/07/2025 12:32, Marc Haber wrote:
    The Natural Philosopher <tnp@invalid.invalid> wrote:
    On 07/07/2025 09:47, Ralf Fassel wrote:
    * The Natural Philosopher <tnp@invalid.invalid>
    | Try it without the error
    | cd ~/Music
    | rm -r *

    I'd rather do

    cd ~/Music && rm -r *

    If the 'cd' fails for any reason, you most definitely don't want
    the "rm -r *" to happen.

    R'
    Nice trick

    rm -r ~/Music would have been too easy?

    TBH whenever I use rm -r I double check to see if I am in the right
    directory FIRST

    rm -r ~/Music will remove the Music directory as well..

    You don't need to be a rocket scientist to come up with rm -f
    ~/Music/*

    Greetings
    Marc
    --
    ---------------------------------------------------------------------------- Marc Haber | " Questions are the | Mailadresse im Header Rhein-Neckar, DE | Beginning of Wisdom " |
    Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fon: *49 6224 1600402

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric Pozharski@21:1/5 to Fritz Wuehler on Mon Jul 7 13:16:29 2025
    with <976fe4c0434b46096bc896f780b8fd69@msgid.frell.theremailer.net>
    Fritz Wuehler wrote:
    Lawrence D'Oliveiro <...@nz.invalid> [LD]:

    Why not do rm -r ~/Music/*
    If any file/dir names in there have spaces or even (shudder)
    newlines, then word-splitting may not produce the results you expect.
    The shell has no problem with such names:
    D=/tmp/test101; mkdir $D && mkdir $D/"a b" $D/"$(printf "a\nc")" &&
    find $D echo deleting everything... rm -fr $D/* && find $D

    I call dibs on this, after

    $ mkdir -v "$( printf "kbdg\nphdh" )"
    mkdir: created directory 'kbdg'$'\n''phdh'
    $ mkdir -v $( printf "lktb\nrkpu" )
    mkdir: created directory 'lktb'
    mkdir: created directory 'rkpu'
    $ mkdir -v "$( printf 'cypd\nfapj' )"
    mkdir: created directory 'cypd'$'\n''fapj'

    I have this:

    $ ls -Ggh
    total 16K
    drwxrwx--- 2 4.0K Jul 7 13:09 cypd\nfapj
    drwxrwx--- 2 4.0K Jul 7 13:06 kbdg\nphdh
    drwxrwx--- 2 4.0K Jul 7 13:08 lktb
    drwxrwx--- 2 4.0K Jul 7 13:08 rkpu


    --
    Torvalds' goal for Linux is very simple: World Domination
    Stallman's goal for GNU is even simpler: Freedom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to The Natural Philosopher on Mon Jul 7 21:53:56 2025
    On Mon, 7 Jul 2025 15:00:05 +0100, The Natural Philosopher wrote:

    rm -r ~/Music will remove the Music directory as well..

    Yeah, but surely it’s no biggie to recreate it.

    Unlike that whole Windows “inetpub” thing ...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuno Silva@21:1/5 to Richard Kettlewell on Fri Jul 11 18:36:29 2025
    On 2025-07-06, Richard Kettlewell wrote:

    Nuno Silva <nunojsilva@invalid.invalid> writes:
    On 2025-07-06, Carlos E.R. wrote:
    Would that problem be different in:

    rm -r ~/Music/*

    compared to:

    cd ~/Music/*
    rm -r *

    “cd ~/Music/*” will not work; you mean “cd ~/Music”.

    I think so, yes. One problem is the same and present in both, word
    splitting will happen after the expansion of *.

    No. Word splitting is first, then expansion. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_01

    (I just wanted to apologize for any confusion or alarm I might have
    caused with that post of mine. It clearly required more caffeine...)

    --
    Sorry,
    Nuno Silva

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)