Skip to content
Advertisement

list file key-pair sorted by time

I need to sort a filename pair sorted by time. Every file starts with AUSZUG or UMSATZ (and some numbers after). But the problem is that I cannot sort it by just time because some files can be uploaded (created) not as pair. For example, default sort:

JavaScript

You can see, UMSATZ pair for AUSZUG_5785745789.TXT.GPG are in last line

I can solve this by sort

JavaScript

But now it’s not by the time 🙁 Anyone idea to sort it by AUSZUG-UMSATZ pair sorted by time?

Advertisement

Answer

I’m not sure if I got you right, I understand that you want to have a list of UMSATZ_* files sorted by time interlaced with the corresponding AUSZUG_* files. You can get this in bash with this one-liner:

JavaScript

The unusually looking ${x#UMSATZ} strips the string UMSATZ from the front of the x variable.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement