Reputation: 3
I have a file where data is like,
Line 1 01~Address~PIN~
Line 2 01~Line~Code~
The output should be
Line 1 01~AddressLine~PINCode~
How can I get this output using bash script?
Upvotes: 0
Views: 34
Reputation: 14949
You can try this awk
:
awk 'BEGIN{OFS=FS="~"} NR%2{f1=$1;f2=$2;f3=$3;next} {print f1,f2$2,f3$3}' file
(Or)
awk 'BEGIN{OFS=FS="~"} NR%2{prev=$0;next} {split(prev,arr,"~");print arr[1],arr[2]$2,arr[3]$3}' file
Upvotes: 1