by pk <pk@[EMAIL PROTECTED]
>
May 6, 2008 at 12:03 PM
On Tuesday 6 May 2008 11:52, Nezhate wrote:
> Hi guys,
> I've a small script that takes some data from file and split each word
> in characters. There is 1 word per line in file.
> For example, file contains 2 words:
> Linux
> foo
>
> the result must be :
>
> L
> i
> n
> u
> x
> f
> o
> o
>
> to do this I used the next command, but it fails
> awk '{for (i=1;i<=NF;i++) {for (j=1;j<=length($i);j++) {print
> $i[j] } } } }' read_text.txt
Use an empty FS:
awk -F '' '{for (i=1;i<=NF;i++) print $i}' read_text.txt
Note that this needs GNU awk.
--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.