You are not logged in.

#26 2021-06-06 14:15:19

lambdarch
Member
Registered: 2021-01-10
Posts: 20

Re: [Solved] Delete old backups from shell

Arciere wrote:

So, I would like to show files and folders, but not the contents of them.

This is what the command I gave in #20 does.

Arciere wrote:

Your #20 first command also deletes the newer backups instead of the older ones...

Oops, sorry, I think I had some kind of brain inversion from the beginning ^^
So just use head instead of tail:

printf '%s\0' /backupFolder/* | head -z -n-11 | xargs -0 rm -rfv

Offline

#27 2021-06-06 14:27:12

Arciere
Member
From: Torino, Italy
Registered: 2020-10-07
Posts: 44

Re: [Solved] Delete old backups from shell

Trilby wrote:

If the input you are `sort'ing or 'tail'ing is delineated by NULL rather than newline, then yes, that's precisely what that flag is for.  Otherwise `sort` will just receive one line of input, so there is nothing to sort and it will output exactly what it was given as input completely unchanged.

Of course, you could quite easily test this yourself rather than asking.

You are expected to read man pages, and make an effort to learn on your own.

Do not take on "help vampire" habits.

My dear Trilby,
I do not consider myself a person who likes to ask others to do something for me, on the contrary... I am here that I keep asking for clarification precisely because I have gaps and I want to fully understand the command I will give to make my backups. I am interested in fully understanding it, and not just copy-paste the command that some good soul has suggested to me, also because otherwise the thread would have stopped at the first answer. My curiosity continually pushes me to ask others and to ask myself questions when I don't understand something, and I'm here to learn from those who know more than me. Finally, I believe that this is the reason why all the users of the forum have registered, and also the very reason why the forum exists. To confirm this, there is also the Arch forum, and not just the Wiki and the man pages of the terminal.
I don't know the content of all your >25k posts, but I wonder if they are all about quantum computing and other things that few in the world still fully understand.
I hope in any case that they live up to your #12, because if they are like this one you did, forgive me but I think they have not been an indispensable contribution to the community.
Forgive me for stealing your precious time, and I renew my thanks for reporting that first link (not the second one on which instead I spread a pitiful veil): I'm devouring it very well smile


Arciere

Offline

#28 2021-06-06 14:29:02

Arciere
Member
From: Torino, Italy
Registered: 2020-10-07
Posts: 44

Re: [Solved] Delete old backups from shell

lambdarch wrote:
Arciere wrote:

So, I would like to show files and folders, but not the contents of them.

This is what the command I gave in #20 does.

Arciere wrote:

Your #20 first command also deletes the newer backups instead of the older ones...

Oops, sorry, I think I had some kind of brain inversion from the beginning ^^
So just use head instead of tail:

printf '%s\0' /backupFolder/* | head -z -n-11 | xargs -0 rm -rfv

Oh my dear, I was not aware of the head command. Thank you so much, I'll try it now!!


Arciere

Offline

Board footer

Powered by FluxBB