Shell & IFS

jty at intrin.UUCP jty at intrin.UUCP
Tue Mar 3 20:16:27 AEST 1987


In article <140 at tdi2.UUCP> brandon at tdi2.UUCP (Brandon Allbery) writes:
>IFS=':
>' # newline and colon
>while read name pass uid gid comment home shell; do
>	# do something with them
>done < /etc/passwd
>
>This is the ONLY way I've seen it used; frankly, I use "awk" if I want to
>process a file in this way anyway, so I see no real use for IFS.

Nope!

IFS comes in handy if you want to parse command output or, say, PATH
----------
: 'this is a functional equivalent to SV sh type command'
IFS=":$IFS"
for CMD
do
	for DIR in $PATH
	do
		if test -x $DIR/$CMD
		then
			echo $DIR/$CMD 
		fi
	done
done
-----------
IFS=":$IFS"
set `date`
echo It\'s $4.$5
-- 
Jyrki Yli-Nokari, Intrinsic Oy, SF-33100 Tampere, FINLAND

USENET:      INTERNET:    BITNET:          FUNET:        TELEPHONE:
intrin!jty   jty at tut.FI   YLI at FINTUTA   TTKKLK::YLI   +358 31 132800



More information about the Comp.unix.wizards mailing list