Solved Arrange Files Alternatively based on File Name

February 26, 2013 at 00:58:41
Specs: Solaris

Hi Experts,

I would like to seek your assistance on achieving the following output:

List of files from ls -lrt

-rw-r--r-- 1test file 45 Feb 26 16:21 TEST2_aa
-rw-r--r-- 1test file 75 Feb 26 16:21 TEST2_ab
-rw-r--r-- 1test file 53 Feb 26 16:21 TEST1_ac
-rw-r--r-- 1test file 43 Feb 26 16:21 TEST1_ad
-rw-r--r-- 1test file 40 Feb 26 16:21 TEST2_ae
-rw-r--r-- 1test file 55 Feb 26 16:21 TEST1_af
-rw-r--r-- 1test file 59 Feb 26 16:21 TEST2_ag
-rw-r--r-- 1test file 26 Feb 26 16:21 TEST1_ah
-rw-r--r-- 1test file 43 Feb 26 16:21 TEST1_ai
-rw-r--r-- 1test file 53 Feb 26 16:21 TEST1_aj

OUTPUT

TEST1_ac
TEST2_aa
TEST1_ad
TEST2_ab
TEST1_af
TEST2_ae
TEST1_ah
TEST2_ag
TEST1_ai
TEST1_aj

Goal: Arrange files alternatively TEST1_*, TEST2_*, TEST1_*, TEST2_* and so on. Note that the number of TEST1 and TEST may not be equal.

I have tried using the ls and piping the output to sort but I did not achieve the target output.

Any input is higly appreciated.

Thanks and Regards,
Amiti


See More: Arrange Files Alternatively based on File Name

Report •


#1
February 26, 2013 at 02:05:52
✔ Best Answer

Already figured out :)

sort +1 +0 -1 -t_


Report •
Related Solutions


Ask Question