AraR87
1
Guys,
i have an input file as below
15|121|US|03/12/15|Y|
15|122|US|03/12/15|Y|
15|123|US|03/12/15|Y|
but i need the output as below using awk command
15|US|121|
15|US|122|
15|US|123|
I used the below command
awk -F"|" '{print $1,$3,$2}' inputfile
i am getting the outout pipe(|). but i need the output with pipe(|) as input file. Please help me on this. Thanks
awk -F"|" 'BEGIN{OFS="|"}{print $1,$3,$2}' inputfile
AraR87
3
Thanks Kumaran. but i am getting as below without pipe (|) for last one. but i need pipe(|) in the last as well.
15|US|121
15|US|122
15|US|123
clx
4
If you just want to print "|" at the end you can explicitly print it.
awk -F"|" '{print $1,$3,$2"|"}' inputfile
EDIT : You sure of getting "|" in output file with the above command? You will need to use OFS="|"
as suggested in another post.
just add "|"
awk -F"|" 'BEGIN{OFS="|"}{print $1,$3,$2"|"}' inputfile
RudiC
6
You could also try to print an empty entity:
awk -F"|" '{print $1,$3,$2,_}' OFS="|" file