I have try with ls comand which only sort the files according to the modification and creating date that UNIX assign to them but that not my goal. The goal is to sort by the date in the filename.
Thanking you in advance.
Hello radoulov,
Thank you very much for your quick reply.
I have tested the code in your reply on my vmware machine for some files in the same format and indeed that really work!.
I will integrate this piece of code in my script tomorrow and test the whole code on my real UNIX machine.
---------- Post updated at 03:21 PM ---------- Previous update was at 03:07 PM ----------
Can you please advise how should the command be if for example the files are different like for example:
Many many thanks to you. That was the way I play with your above reply:
Infact on production the filename has the following format:
IGL01_AC_D_<YYYYMMDD>_<N01>_<01>.dat where all the paramaters in angular brakets can be changed. N01 becomes N02 etc, 01 becomes 02 03 etc and
<YYYYMMDD> also.
From your code, I undertstood that -k4,4 is the position in the filename on which I want to sort..am i right?
I used your above logic to sort the file on the three columns with :
There is no substitute for testing things out yourself. Have a go and see what you get. It is simple enough to create a directory for testing and then use touch to create a bunch of files with the name in the correct format with enough variations to have a go with the code you have.
If there is more required, please show what you have tried and what your files are listed as and what you are trying to acheive. There are some subtle differences in the version of sort on some flavours of unix, so we might be breaking its rules somewhere.
I will try some and get back to you but nevertherless I'm really satisfied with the answers given in the forums here because the modification I made to my shell works well and is already on prod env
Big applause and thanks to you all. I will play around with some more command and get back soon.