try this:
awk -F- -v OFS="-" '{for(i=NF-1;i>=1;i--){l=length($i);if(l<2||l>3)$(i+1)=" "$(i+1)}}7' file
the above line apply your rule for every -
: for example:
kent$ cat f
SB-743921- 11C
SBDF-559448-AAA
SBI-742457-A
S-SANJAY PFF
GH222016/Love
kent$ awk -F- -v OFS="-" '{for(i=NF-1;i>=1;i--){l=length($i);if(l<2||l>3)$(i+1)=" "$(i+1)}}7' f
SB-743921- 11C
SBDF- 559448- AAA
SBI-742457- A
S- SANJAY PFF
GH222016/Love
if you just want to check the column before the first -
, it would be much easier.
only apply on the first case:
awk -F- -v OFS="-" 'NF>1{l=length($1);if(l<2||l>3)$2=" "$2}7' file