Hi, Guys. Please help me to find solution to this problem using shell scripting.
I have an INPUT file with 4 columns separated by tab. Each block of records is separated by -----
-----
Sample1 5402 6680 Pattern01
Sample2 2216 2368 Pattern02
Sample3 1932 2122 Pattern09
-----
Sample1 75209 76057 Pattern05
Sample2 76269 76713 Pattern01
Sample3 82346 82510 Pattern07
Sample4 82606 82796 Pattern06
-----
sample1 41587 44548 Pattern90
-----
I need to print rows in reverse order if values decrease along the column in a particular Block and to print the Block as it is if there is a single record or the column values are in increasing order.
Required OUTPUT is :
-----
Sample3 1932 2122 Pattern09
Sample2 2216 2368 Pattern02
Sample1 5402 6680 Pattern01
-----
Sample1 75209 76057 Pattern05
Sample2 76269 76713 Pattern01
Sample3 82346 82510 Pattern07
Sample4 82606 82796 Pattern06
-----
sample1 41587 44548 Pattern90
-----
Thanks in advance.