Inserting space between each letter
$ echo -e "How are you\n everything alright" | sed 's/./& /g'
H o w a r e y o u
E v e r y t h i n g a l r I g h t
The disadvantage is that the natural space between each word is doubled. To remedy this small inconvenience just add:
The problem is that the natural space between each word is doubled. To remedy to this , you just have to insert
$ echo -e " How are you \n everything alright " | sed 's/./& /g;s/ / /g'
H o w a r e y o u
E v e r y t h i n g a l r i g h t
$
Below is a variant. Compared to the previous replacement and done once s / / /
$ echo -e " How are you \n everything alright" | sed -r 's/([^ ])/\1 /g'
How are you
E v e r y t h i n g a l r i g h t
To avoid using option –r we can write
ur not use the -r option can be written
sed 's/\([^ ]\)/\1 /g'
Character class complemented [^...]
".
[^...] - Is a character class complemented which means "recognize a non-listed" and not "not to recognize a listed".
In our case we can translate "recognize a character that is not space".
$ echo -e "How are you\n everything alright" | sed 's/./& /g'
H o w a r e y o u
E v e r y t h i n g a l r I g h t
L'inconvénient c'est que l'espace naturel entre chaque mot est doublé. Pour pallier à ce petit désagrément il suffit d'ajouter :
The disadvantage is that the natural space between each word is doubled. To remedy this small inconvenience just add:
The problem is that the natural space between each word is doubled. To remedy to this , you just have to insert
$ echo -e " How are you \n everything alright " | sed 's/./& /g;s/ / /g'
H o w a r e y o u
E v e r y t h i n g a l r i g h t
$
Below is a variant. Compared to the previous replacement and done once
s / / /
$ echo -e " How are you \n everything alright" | sed -r 's/([^ ])/\1 /g'
How are you
E v e r y t h i n g a l r i g h t
To avoid using option
–r we can write
ur not use the -r option can be written
sed 's/\([^ ]\)/\1 /g'
Character class complemented [^...]
".
[^...] - Is a character class complemented which means "recognize a non-listed" and not "not to recognize a listed".
In our case we can translate "recognize a character that is not space".