recursive grep

John Chambers jc at minya.UUCP
Tue Sep 26 05:53:55 AEST 1989


> There is this incredible feeling of power in being able to type:
> 	oifs=IFS
> 	IFS=":"
> 	while read login passwd uid gid tail;do
> 		# some processing for all the logins on the system
> 	done </etc/passwd
> 	IFS=oifs
> whenever I feel like it.

Well, I tried this, adding the two missing dollars, of course; in
particular I tried:

|	oifs=$IFS
|	IFS=":"
|	while read login passwd uid gid descr dir shell
|	do	echo dir=$dir
|	done </etc/passwd
|	IFS=$oifs

It worked for some lines, but for any line that had a null field (e.g.,
several had no password, and some of the system accounts had null descr
fields), the "while read" line ignored all the null fields, causing the
wrong value to be assigned to all the subsequent fields.

And it seemed like such a good idea.  It'd be real useful to have such
an elegant way to extract all the home directories.  I've tried using
awk for the same job, with similar results.

At least sed can handle it.

Sigh.

-- 
#echo 'Opinions Copyright 1989 by John Chambers; for licensing information contact:'
echo '	John Chambers <{adelie,ima,mit-eddie}!minya!{jc,root}> (617/484-6393)'
echo ''
saying



More information about the Comp.unix.wizards mailing list