string split, bash and IFS

Unga unga888 at yahoo.com
Mon Aug 25 09:39:39 UTC 2008


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


      


More information about the freebsd-questions mailing list