1

I want to get this string -> Example example1

in this form:

E  
x  
a  
m  
p  
l  
e

e  
x  
a  
m  
p  
l  
e  
1  
fedorqui
  • 275,237
  • 103
  • 548
  • 598

2 Answers2

4

Use fold utility with width=1:

echo 'Example example1' | fold -w1
E
x
a
m
p
l
e

e
x
a
m
p
l
e
1

Another option is grep -o:

echo 'Example example1' | grep -o .
E
x
a
m
p
l
e

e
x
a
m
p
l
e
1
anubhava
  • 761,203
  • 64
  • 569
  • 643
1

Using standard unix tools, you can do, for example:

echo "Example example1" | sed 's/\(.\)/\1\n/g'

Using pure bash:

echo "Example example1" | while read -r -n 1 c ; do echo "$c"; done

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142