How to delete multiple changes subdir at once ? <SOLVED>

a very small Live CD shaped to look and act like Puppy Linux.


Moderator: fredx181

Post Reply
dcung
Posts: 510
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 68 times
Been thanked: 70 times

How to delete multiple changes subdir at once ? <SOLVED>

Post by dcung »

This probably should be in scripting section, but take less effort for me to explain to @fredx181 what I'm trying to do. So, I post it here. Apology.

When I do a refresh, I end up with a directory like this.

2025-03-02-112505_934x740_scrot-1.png
2025-03-02-112505_934x740_scrot-1.png (253.32 KiB) Viewed 1285 times

.
.
.
I then do some test/tinkering, and the changes dir is located under each frugal-install-dir, like so

2025-03-02-112516_934x740_scrot-1.png
2025-03-02-112516_934x740_scrot-1.png (109.63 KiB) Viewed 1285 times

.
.
.
I want to have a script (sort of a reset), where I can delete all changes dir under each frugal-install-dir at once, without visiting each frugal-install-dir manually.

Code: Select all

#!/bin/bash

for each frugal-install-dir
	delete frugal-install-dir/changes (content and subdirs).
Last edited by dcung on Sun Mar 02, 2025 7:24 am, edited 1 time in total.
User avatar
fredx181
Posts: 3385
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 437 times
Been thanked: 1484 times
Contact:

Re: How to delete multiple changes subdir at once ?

Post by fredx181 »

dcung wrote:

I want to have a script (sort of a reset), where I can delete all changes dir under each frugal-install-dir at once, without visiting each frugal-install-dir manually

.

Would this be ok ? (will delete every changes dir it can find in bookworm-2025-02-28)
find /mnt/sda3/bookworm-2025-02-28 -type d -name changes | xargs rm -r

dcung
Posts: 510
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 68 times
Been thanked: 70 times

Re: How to delete multiple changes subdir at once ? <SOLVED>

Post by dcung »

fredx181 wrote: Sun Mar 02, 2025 6:47 am

Would this be ok ? (will delete every changes dir it can find in bookworm-2025-02-28)
find /mnt/sda3/bookworm-2025-02-28 -type d -name changes | xargs rm -r

That did it.
Thanks! Save me from manual labour... :thumbup2:

2025-03-02-182013_810x389_scrot.png
2025-03-02-182013_810x389_scrot.png (293.4 KiB) Viewed 1228 times
gumanzoy
Posts: 149
Joined: Mon May 03, 2021 3:38 pm
Has thanked: 29 times
Been thanked: 40 times
Contact:

Re: How to delete multiple changes subdir at once ? <SOLVED>

Post by gumanzoy »

dcung wrote: Sun Mar 02, 2025 1:15 am

I want to have a script (sort of a reset), where I can delete all changes dir under each frugal-install-dir at once, without visiting each frugal-install-dir manually.

Code: Select all

rm -rf /mnt/sda3/bookworm-2025-02-28/bookworm-*/changes

PocketHandyBox (Debian 12 "Bookworm" with NVIDIA drivers OOTB)

dcung
Posts: 510
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 68 times
Been thanked: 70 times

Re: How to delete multiple changes subdir at once ? <SOLVED>

Post by dcung »

@fredx181
I use my kid scripting skill combined with what you have provided in the past (run-in-xterm very useful for me) + google, to make this (and other scripts actually).
It let me see what's to be deleted before continuing.

If you see things to improve/shorten, let me know.

Code: Select all

#!/bin/bash

# function run_in_xterm
run_in_xterm () {
echo
echo
echo
read -sp "Remove ALL CHANGES dirs. Press ENTER to continue or Ctrl-C to Cancel. . ."
echo
echo

if find . -type d -name changes -exec false {} +
then
  echo 'No CHANGES dirs found'
else
  find . -type d -name changes
  echo
  echo
  read -sp "Dir Listed above will be REMOVED. Press ENTER to continue or Ctrl-C to Cancel. . ."
  echo
  find . -type d -name changes | xargs rm -r
fi

echo
echo
read -sp "Press ENTER to close window. . ."
}
export -f run_in_xterm

# run function 'run_in_xterm' from xterm
xterm -T "Remove CHANGES dirs" -e /bin/bash -c run_in_xterm
User avatar
fredx181
Posts: 3385
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 437 times
Been thanked: 1484 times
Contact:

Re: How to delete multiple changes subdir at once ? <SOLVED>

Post by fredx181 »

@dcung nice !

If you prefer, you can make the actual removal show more verbose:
find . -type d -name changes | xargs rm -rv

Btw, just curious, what is exactly your purpose by the "refreshing" so many builds frequently ?
(probably you said once, but can't remember what)
And isn't the "pseudo full" install perhaps more convenient way for you then ? (as then the 'refresh' is done "in place", e.g. when doing apt upgrade)
edit: btw, even the kernel (also generating new initrd1.xz) can be upgraded on "pseudo full" with the alternate initramfs-tools package. More info: viewtopic.php?p=140395#p140395

dcung
Posts: 510
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 68 times
Been thanked: 70 times

Re: How to delete multiple changes subdir at once ? <SOLVED>

Post by dcung »

fredx181 wrote: Tue Mar 04, 2025 7:19 am

Btw, just curious, what is exactly your purpose by the "refreshing" so many builds frequently ?
(probably you said once, but can't remember what)
And isn't the "pseudo full" install perhaps more convenient way for you then ? (as then the 'refresh' is done "in place", e.g. when doing apt upgrade)
edit: btw, even the kernel (also generating new initrd1.xz) can be upgraded on "pseudo full" with the alternate initramfs-tools package. More info: viewtopic.php?p=140395#p140395

No special reason really.

I have many old computers/laptops/servers - sort of junk collector/hoarder.
And rather than running apt update/upgrade individually on each, I just replace it with new build if/when I happen to pick one to tinker. I usually don't have that I need to keep (OS wise), and besides, if a computer needs 'customization' this force me to practice/remember what I did on it when I re-visit.

I didn't know puppy/dog at all in the beginning. I just sampled one by one.
I like most if not all found here, but eventually sort of settled on dog.

In the beginning, I haven't made up my mind which DOG desktop I like best, each has thing that I like, so I just build them and play. I put/play different DE on different computer just for the heck of it.

It also gives me motivation/goal to learn scripting and I 'practice' using/modifying your script.
Especially now, 'refresh' is just pressing a button, make coffee/breaky and they're ready when I got back.

And I like to have a set of 'fresh' build handy/ready when I help friends/family.

Most of what I know now is of course thanks to you (and many members of this forum).

On my main laptop, I don't 'refresh' often....(often enough though)
Well, that's the beauty of 'frugal' install, at least for me.

Post Reply

Return to “DebianDogs”