I am trying to get 20th character of each line, if its b then exchange last 2 columns with each other values AND if its B then 3rd last column and last column's value should be exchanged, like shown below.
Sample of input:
1234567891011121314b abcd erfg ijkl 12114353 blabla
1234567891011121314Babcd erfg ijkl 12114353 blabla
Sample of expected output:
1234567891011121314b abcd erfg ijkl blabla 12114353
123456789101112131Babcd erfg blabla 12114353 ijkl
I tried following code:
while read value
do
echo "$value" | cut -c20
done < "file"
I also tried to use awk's substr but couldn't proceed too much in it too.
Actual file is same like shown sample above; please guide me.