I have a input string with |
[pipe] delimiter and like to replace the empty string 3rd and 5th column by &
character.
Input File:
a a|b b|c c|d d|e e
f f|g g|h h|i i|j j
Output File:
a a|b b|c&c|d d|e&e
f f|g g|h&h|i i|j&j
You can see the space between cc, ee, hh and jj
is replaced with &
I have an alternate solution which involves read file using while loop and by using cut
command based on delimiter and storing it in variable based on position and replacing the space by '&' using sed
and append all the splitted variable in to one variable and append it in a new file. Is there a single command which can be used to achieve this?