I need to print the following sequence for illustration purposes in two columns
a-z
which has alphabets from a to z such that they are in 13-character columns.
How can you echo the characters from a to z into two columns?
I need to print the following sequence for illustration purposes in two columns
a-z
which has alphabets from a to z such that they are in 13-character columns.
How can you echo the characters from a to z into two columns?
Better solutions exist, I'm sure, but I'll give it a shot:
$ echo "abcdefghijklmnopqrstuvwxyz" | sed -e 's/\(.\)\(.\)/\1 \2\n/g'
a b
c d
e f
g h
i j
k l
m n
o p
q r
s t
u v
w x
y z
Very nice Stephan,
How about avoiding to type a through z with a loop?
for i in {a..z}; do echo -n $i; done | sed -e 's/\(.\)\(.\)/\1 \2\n/g'
Your question did not specify how to distribute the characters in the two coloumns, so here is an alternative answer:
prompt> paste <(echo "abcdefghijklm" | sed 's/\(.\)/\1\n/g' ) <(echo "nopqrstuvwxyz" | sed 's/\(.\)/\1\n/g')
a n
b o
c p
d q
e r
f s
g t
h u
i v
j w
k x
l y
m z
prompt>