Member
Registered: Apr 2004
Posts: 340
Original Poster
Rep:
|
sort -t, -k3 -k1 ./a1.txt
works perfectly on this file:
"blue","right","mhduei573","0","0"
"pink","left","bvop4967","0","0"
"yellow,"top","zpbm2368","0","0"
"green","right","cdw432lmjt","0","0"
"purple,"left","plmnhy3zd21","0","0"
"white","top","yg36c0wxqa","0","0"
"blue","left","bvop4967","0","0"
"pink","top","yg36c0wxqa","0","0"
"gray,"right","bvop4967","0","0"
It results in:
"blue","left","bvop4967","0","0"
"gray,"right","bvop4967","0","0"
"pink","left","bvop4967","0","0"
"green","right","cdw432lmjt","0","0"
"blue","right","mhduei573","0","0"
"purple,"left","plmnhy3zd21","0","0"
"pink","top","yg36c0wxqa","0","0"
"white","top","yg36c0wxqa","0","0"
"yellow,"top","zpbm2368","0","0"
Exactly what I needed.
To take it a step further, I need to group the data by the 3rd field.
So that it adds a blank line every time there is a change in the 3rd field.
How do you make it look like this?
"blue","left","bvop4967","0","0"
"gray,"right","bvop4967","0","0"
"pink","left","bvop4967","0","0"
"green","right","cdw432lmjt","0","0"
"blue","right","mhduei573","0","0"
"purple,"left","plmnhy3zd21","0","0"
"pink","top","yg36c0wxqa","0","0"
"white","top","yg36c0wxqa","0","0"
"yellow,"top","zpbm2368","0","0"
|