[net.unix-wizards] does anybody use IFS in sh?

tim@callan.UUCP (06/05/84)

 ever use IFS?  Is this a new topic?  Just curious ...
-- 
"Now Groo does what Groo does best!"
				    {decvax,ucbvax,ihnp4}!cithep!tim
Tim Smith		{decvax,ucbvax,cithep}!trwrb!wlbr!callan!tim
					       ihnp4!wlbr!callan!tim

tim@callan.UUCP (06/05/84)

[]

My last attempt at this got garbled.  Forgive me if you have seen this:

Does anybody else ever use IFS?  Is this a new topic?  Just curious ...
-- 
"Now Groo does what Groo does best!"
				    {decvax,ucbvax,ihnp4}!cithep!tim
Tim Smith		{decvax,ucbvax,cithep}!trwrb!wlbr!callan!tim
					       ihnp4!wlbr!callan!tim

tony@asgb.UUCP (06/07/84)

I've seen people add a comma to IFS so they can do things like:

	cat a,b,c,d

Tony Andrews
Burroughs Corp.
ihnp4!sdcrdcf!bmcg!asgb!tony

honey@down (code 101) (06/08/84)

i use IFS in my "path" command (sh version of "which"):

	#! /bin/sh
	IFS="${IFS}:"
	for arg do
		file=`basename ${arg}`
		for directory in $PATH; do
			if [ -x ${directory}/${file} ]; then
				echo ${directory}/${file}
			fi
		done
	done

'course i had to haq up test to use -x ...

once upon a time bourne and i bet a quarter on who could cons up a
better script for this ... i spent my winnings chomping inky, blinky,
pinky, and sue.  (he used sed -e 's/:/ /g' on $PATH.)
	peter honeyman

yba@mit-athena.UUCP (06/18/84)

I have also found changing IFS to newline to be useful in using
the "for" construct to iterate over a list of complicated items.
Typically these items were output by "awk" and had several fields
which I wanted bound to one shell variable.

dave@qtlon.UUCP (Dave Lukes) (06/21/84)

What do you mean you had to hack test to use `-x' ??

It's only brain-damaged systems like 4.[12] that did `-[rw]' but not -x !

ignatz@ihuxx.UUCP (Dave Ihnat, Chicago, IL) (06/22/84)

Certainly.  IFS is extremely useful in shellscripts that deal with
such things as PATH or VPATH...

		Dave Ihnat
		ihuxx!ignatz