Path: utzoo!attcan!uunet!vsedev!logan From: logan@vsedev.VSE.COM (James Logan III) Newsgroups: comp.unix.wizards Subject: Re: This is strange... Keywords: sed awk pipe Message-ID: <1275@vsedev.VSE.COM> Date: 23 Dec 88 16:10:32 GMT References: <1652@ektools.UUCP> Reply-To: logan@vsedev.VSE.COM (James Logan III) Organization: VSE Software Development Lab Lines: 41 In article <1652@ektools.UUCP> mcapron@ektools.UUCP (M. Capron) writes: # # CODE A: This works. # incs=`egrep '^#[ ]*include[ ]*"' $i | awk '{printf "%s ", $2}'` # incs=`echo "$incs" | sed 's/"//g'` # # CODE B: This does not work. # incs=`egrep '^#[ ]*include[ ]*"' $i | awk '{printf "%s ", $2}' | sed 's/"//g'` # Someone else already answered your question correctly, but I have another version for you that handles all of the following cases: #include #include "file" # include # include "file" and runs a little faster, since it is all contained in one awk script and does not required additional processing by sed. incs=` awk ' /^#[ ]*include[ ]*/ { if (NF == 3) { # line is like "# include " INCFILE=$3; } else { # line is like "#include " INCFILE=$2; } print substr(INCFILE, 2, length(INCFILE) - 2); } ' <$i; `; -Jim -- Jim Logan logan@vsedev.vse.com (703) 892-0002 uucp: ..!uunet!vsedev!logan inet: logan%vsedev.vse.com@uunet.uu.net