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
  • 252,262
  • 96
  • 511
  • 570

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
  • 713,503
  • 59
  • 514
  • 593
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

PSkocik
  • 55,062
  • 6
  • 86
  • 132