Sample Header Ad - 728x90

How to compare two file names

1 vote
2 answers
2174 views
I want to compare two files in a folder and delete the number in the name which is the smaller of the two. For instance, say the names were yearMonthDay.txt. I want to compare which is a smaller number and sudo rm it. I know I can get the numbers via:
find *txt | awk -F'[_.]' '{ print $1}'
How then next should I compare it? Using system variables? I actually haven't used shell variables before.
Asked by 1toneboy (465 rep)
Nov 27, 2021, 02:26 AM
Last activity: Jun 25, 2025, 01:07 PM