I would like find and delete old backup files in aix. How would I go about doing this? For example:
server1_1-20-2020
server1_1-21-2020
server1_1-22-2020
server1_1-23-2020
server2_1-20-2020
server2_1-21-2020
server2_1-22-2020
server2_1-23-2020
How would I go about finding and deleting old backup files? I would like to be left with only this after deleting the old backups.
server1_1-23-2020
server12_1-23-2020
Duplicate means has the same identical data. From your comment I think you want something else - like the intent - what the file represents.
If you really mean duplicate, a simple checksum cksum
will do as a start:
cksum server1_1* | sort -n
If you want filetimes or something else please give the specifics.
I guess you mean the file names?
Then consider sort and unique to sort out duplicates.
Show the duplicate file names:
$ sort your_example | uniq -d
server2_1-23-2020
Show the non-duplicates:
$ sort your_example | uniq -u
server1_1-20-2020
server1_1-21-2020
server1_1-22-2020
server2_1-20-2020
server2_1-21-2020
server2_1-22-2020
Show each file name once
$ sort your_example | uniq
$ sort -u your_example
server1_1-20-2020
server1_1-21-2020
server1_1-22-2020
server2_1-20-2020
server2_1-21-2020
server2_1-22-2020
server2_1-23-2020
I apologize for the bad title and description. I have updated the title and description.