Hi. I am a windroid but I still have ubuntu partition with working Ubucd ~/Music
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.
On 05/07/2025 13:26, bilsch01 wrote:
Hi. I am a windroid but I still have ubuntu partition with working Ubucd ~/Music
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.
rm - r *
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 *
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 *
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 workingcd ~/Music
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.
rm - r *
for each directory it says: cannot remove because that is a directory
On 05/07/2025 13:26, bilsch01 wrote:
what is linux shell command to delete all subdirectories in Music?
cd ~/Music
rm - r *
On 7/5/25 06:36, Charlie Gibbs wrote:
On 2025-07-05, The Natural Philosopher <tnp@invalid.invalid> wrote:it worked good Thanks
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 *
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:it worked good Thanks
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 *
And be absolutely positively sure you are where you think you are (via pwd) when running that! I write from bitter experience.
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:it worked good Thanks
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 *
And be absolutely positively sure you are where you think you are (via
pwd)
when running that! I write from bitter experience.
--
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:it worked good Thanks
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 *
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.
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:it worked good Thanks
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 *
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.
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
what is linux shell command to delete all subdirectories in Music?
Why not do
rm -r ~/Music/*
?
(Or were there *files* directly under ~/Music that were intended to be preserved?)
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:it worked good Thanks
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 *
And be absolutely positively sure you are where you think you are (via pwd) when running that! I write from bitter experience.
Jason H wrote:Be careful that news readers may display text with slashes and asterisks
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"
Carlos E.R. wrote:
Jason H wrote:Be careful that news readers may display text with slashes and asterisks
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"
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∕*
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.
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 *
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 *
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.
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.)
On 2025-07-06, Carlos E.R. wrote:
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".
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.
If any file/dir names in there have spaces or even (shudder)expect.
newlines, then word-splitting may not produce the results you LD>
The shell has no problem with such names:
* The Natural Philosopher <tnp@invalid.invalid>Nice trick
| 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'
On 07/07/2025 09:47, Ralf Fassel wrote:
* The Natural Philosopher <tnp@invalid.invalid>Nice trick
| 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'
The Natural Philosopher <tnp@invalid.invalid> wrote:
On 07/07/2025 09:47, Ralf Fassel wrote:
* The Natural Philosopher <tnp@invalid.invalid>Nice trick
| 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'
rm -r ~/Music would have been too easy?
Greetings
Marc
The Natural Philosopher <tnp@invalid.invalid> wrote:
On 07/07/2025 12:32, Marc Haber wrote:
The Natural Philosopher <tnp@invalid.invalid> wrote:TBH whenever I use rm -r I double check to see if I am in the right
On 07/07/2025 09:47, Ralf Fassel wrote:
* The Natural Philosopher <tnp@invalid.invalid>Nice trick
| 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'
rm -r ~/Music would have been too easy?
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
On 07/07/2025 12:32, Marc Haber wrote:
The Natural Philosopher <tnp@invalid.invalid> wrote:TBH whenever I use rm -r I double check to see if I am in the right
On 07/07/2025 09:47, Ralf Fassel wrote:
* The Natural Philosopher <tnp@invalid.invalid>Nice trick
| 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'
rm -r ~/Music would have been too easy?
directory FIRST
rm -r ~/Music will remove the Music directory as well..
Lawrence D'Oliveiro <...@nz.invalid> [LD]:
The shell has no problem with such names: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.
D=/tmp/test101; mkdir $D && mkdir $D/"a b" $D/"$(printf "a\nc")" &&
find $D echo deleting everything... rm -fr $D/* && find $D
rm -r ~/Music will remove the Music directory as well..
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
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 09:17:16 |
Calls: | 10,387 |
Calls today: | 2 |
Files: | 14,060 |
Messages: | 6,416,669 |