Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: split word ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 5 Topic 2230 of 2236
Post > Topic >>

Re: split word in characters

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.




 5 Posts in Topic:
split word in characters
Nezhate <mazouz.nezhat  2008-05-06 02:52:55 
Re: split word in characters
Ed Morton <morton@[EMA  2008-05-06 05:00:25 
Re: split word in characters
pk <pk@[EMAIL PROTECTE  2008-05-06 12:03:42 
Re: split word in characters
Ed Morton <morton@[EMA  2008-05-06 05:34:04 
Re: split word in characters
Nezhate <mazouz.nezhat  2008-05-06 03:38:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 22:26:49 CDT 2008.