I have a text document that has a load of text which has an extra space added after every letter!
Example:
T h e b o o k a l s o h a s a n a n a l y t i c a l p u r p o s e w h i c h i s m o r e i m p o r t a n t…
Visually:
T␣h␣e␣␣b␣o␣o␣k␣␣a␣l␣s␣o␣␣h␣a␣s␣␣a␣n␣␣a␣n␣a␣l␣y␣t␣i␣c␣a␣l␣␣p␣u␣r␣p␣o␣s␣e␣␣w␣h␣i␣c␣h␣␣i␣s␣␣m␣o␣r␣e␣␣i␣m␣p␣o␣r␣t␣a␣n␣t…
Note that there is an extra space after every letter, so there are two spaces between consecutive words.
Is there a way that I can get awk
or sed
to delete the extra spaces?
(Unfortunately this text document is massive and
would take a very long time to go through manually.)
I appreciate that this is probably a much more complex problem to solve with just a simple bash script as there needs to be some sort of text recognition also.
How can I approach this problem?
echo 'T h i s ; i s .a n 9 8 e x a m p l e' | perl -pe 's/[a-z]\K (?=[a-z])//ig'