[clug] easier way to use IFS in bash?

Steven Hanley sjh at svana.org
Tue Aug 10 01:52:13 GMT 2004

On Tue, Aug 10, 2004 at 11:46:00AM +1000, David Tulloh wrote:
> I'm not sure if you would consider this cheating, but personally I would 
> use awk:
> pos=0 # or whatever you are after
> res=`echo "$var" | awk -v pos=$pos '{print $(pos+1)}'`

We were deliberately atempting to avoid using awk (ie do it in native bash
and not forking to a non bash process or anything)

At the moment we are indeed using awk to do the task, we just wondered if
there was a less kludgey seeming way to do it in BASH, considering there is
the IFS default setting there already one would expect there would be some
way to split up strings according to IFS.

	See You

sjh at wibble.net http://svana.org/sjh
You are subtle as a window pane standing in my view
but I will wait for it to rain so that I can see you
   Anticipate - Ani

More information about the linux mailing list