I have an input file with the following fields:
1) FLD1 X(2)
2) FLD2 X(1)
3) FLD3 X(3)
4) FLD4 X(4)
INPUT:
----|----|----|
11AXXX9999 <- (1)
11AYYY9999 <- (2)
13AZZZ9999 <- (3)
21BXXX9999 <- (4)
22BXXX9999 <- (5)
2) FLD2 X(1)
3) FLD3 X(3)
4) FLD4 X(4)
INPUT:
----|----|----|
11AXXX9999 <- (1)
11AYYY9999 <- (2)
13AZZZ9999 <- (3)
21BXXX9999 <- (4)
22BXXX9999 <- (5)
I need to split all rows in the file into 2 separate files using the following rules:
1) Group all rows by FLD2 and sort by FLD1 AND FLD3 in ascending order
2) Put first row in each group into one file and put remaining rows in each group into another file
3) Combine FLD1 and FLD3 into a new field and place at the beginning of each row
Below is the expected output. Could anyone advise how this can be accomplished using SORT?
OUTPUT 1:
----|----|----|
11XXX11AXXX9999 <- (1)
21XXX21BXXX9999 <- (4)
OUTPUT 2:
----|----|----|
11YYY11AYYY9999 <- (2)
13ZZZ13AZZZ9999 <- (3)
22XXX22BXXX9999 <- (5)
----|----|----|
11XXX11AXXX9999 <- (1)
21XXX21BXXX9999 <- (4)
OUTPUT 2:
----|----|----|
11YYY11AYYY9999 <- (2)
13ZZZ13AZZZ9999 <- (3)
22XXX22BXXX9999 <- (5)
Thanks.