Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Aug 2008 02:39:38 -0700 (PDT)
From:      Unga <unga888@yahoo.com>
To:        freebsd-questions@freebsd.org
Subject:   string split, bash and IFS
Message-ID:  <499449.17617.qm@web57002.mail.re3.yahoo.com>

next in thread | raw e-mail | index | archive | help
Hi all

How to use bash and IFS to split a string?

eg. 
$string = "Name:Surname:10"
IFS=:
echo "$string" | read name surname age

This does not work for some reason. The read does not create name, surname and age variables. Any idea why?

Appreciate your reply.

Kind regards
Unga


      



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?499449.17617.qm>