anshaa
1
Hi,
I need some iteration to do the following work.
Sample:
ANS|26-Jan-2012|26|MON|12536.1
ANS|26-Jan-2012|26|TUE|2536.1
ANS|26-Jan-2012|26|THUR|789.1
SED|26-Jan-2013|32|MON|258.1
SED|26-Jan-2013|32|TUE|369.1
SED|26-Jan-2013|32|THUR|2145.1
OUTPUT:
ANS|26-Jan-2012|26|MON|12536.1|2536.1|789.1
SED|26-Jan-2013|32|MON|258.1|369.1|2145.1
What exactly have you tried so far and where are you stuck?
anshaa
3
i am new to unix, need some method to do the following case.
Jotne
4
Simple approach.
awk -F\| '{printf "%s|", $0;getline;printf "%s|", $5;getline;print $5}' infile
---------- Post updated at 19:59 ---------- Previous update was at 19:27 ----------
A more complex version that need some polishing.
awk -F\| '{if (f!=$1) {print "";printf "%s|", $0;f=$1} else printf "%s|", $5}' infile
ANS|26-Jan-2012|26|MON|12536.1|2536.1|789.1|
SED|26-Jan-2013|32|MON|258.1|369.1|2145.1|