Ads

Check out value in brief website for more up-to-date content.

how to split from word to letter ?

in linux terminal or bash script

%%bash

echo "Michael" | grep -o '.'

M

i

c

h

a

e

l

or in Python

%%python3

from re import findall

print(*findall('.', 'Michael'), sep='\n')

M

i

c

h

a

e

l

or just this

print(*list("Michael"), sep="\n")

or using Perl

echo "Michael" | perl -ne'print join("\n", split(//))'

or another way using Perl

perl -E'say for split//,"Michael"'

or

perl -E'say for "Michael"=~m/(.)/g'

or

perl -E'say for unpack"(A)*","Michael"'

If you want to get new posts, make sure to subscribe to Value In Brief by Email.