I have file abc.txt which has spaces on some lines. Some lines have 4 spaces while some have more than 4 spaces. I want to convert 1st 4 spaces into a tab leaving reast of the spaces as it. I tried
unexpand -t 4 --first-only abc.txt > efg.txt
and also some sed equivalents. They converted all my spaces to tab but not only the first occurrence of 4 space sequence. How can this be achieved in shell and ruby?