Hello all

I am trying to create a script to do the following:

I have a file which contains the following

STEPHEN;CHRIS:PETER>JOHN|

What i need to do is read this file in and be able to seperate the above names into variables based on the delims.

ie

Script something like this

DELIMS=";:>|"

while read name1 name2 name3
do

echo "name1 name2 name3"

done < file.in


Can anyone help or assist?

IS IFS the way forward?

Thanks

while read text
do
  echo "$text" | sed 's#[|:;>]# #g' | read nm1 nm2 nm3 nm4
  echo "$nm1 $nm2 $nm3 $nm4"
done < inputfile
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.