Print a horizontal word vertically.

Say I have the word:

zinger

I want to change it to print

z
i
n
g
e
r

This is for a sorting algorithm that I am testing out. I will then use sort on the vertical and change it back to horizontal printing using tr. Once it is horizontal again, I can compare that sorted jumble against a dictionary doing the same munging. It should give me all the words that use the same letters with the same frequency.

Unfortunately, I am having a brain fart and can't figure out how to get sed to convert this from horizontal to vertical.

I tried this:

sed -e 's/(.)/\1\n/g'

but it doesn't work. It says that my back reference on the right hand side is wrong.

Any help would be appreciated.

Jim

one way:

#!/bin/ksh

printf $(echo '1234' | sed 's/./&\\n/g' )
echo 'zinger' | sed 's/./&\
/g'
echo zinger | awk '{gsub(".","&\n");printf "%s",$0}'
echo zinger | nawk '{gsub(".","&\n")}1' ORS=
# echo "zinger" | fold -b1
z
i
n
g
e
r

@Ghostdog, fold -b1 will throw the below error:

#  echo "zinger" | fold -b1
fold: illegal option -- 1
Usage: fold [-bs] [-w width | -width ] [file...]

The correct usage is:

# echo "zinger" | fold -bw 1
z
i
n
g
e
r

Regards,

Praveen