Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!vsedev!logan From: logan@vsedev.VSE.COM (James Logan III) Newsgroups: comp.unix.questions Subject: Re: Help with strings in Bourne shell Message-ID: <1493@vsedev.VSE.COM> Date: 24 Apr 89 20:27:47 GMT References: <10166@orstcs.CS.ORST.EDU> Reply-To: logan@vsedev.VSE.COM (James Logan III) Distribution: usa Organization: VSE Software Development Lab Lines: 53 In article <10166@orstcs.CS.ORST.EDU> rudolf@oce.orst.edu (Jim Rudolf) writes: # If I have a Bourne script called 'foo' and I call it with the arguments: # foo "color = red" "size = big" # then from within foo they will be read as: # $1 = "color = red" # $2 = "size = big" # However, I want to read from stdin (or maybe a redirected pipe), and I # can't get it to work no matter what strange combination of quotes I use! # I would like to do something like: # read args # for i in $args # . # . # so I can process each string in turn. If I have interpreted your question correctly, you want to read the lines color = red size = big into your script and have each line read into a variable. To do this, use the construct: while read DEFINITION; do echo "$DEFINITION"; . . . done; BTW, you can also read from a specific file by redirecting the input to the read command like this: INPUTFILE="some_file"; while read DEFINITION <$INPUTFILE; do echo "$DEFINITION"; . . . done; -Jim -- Jim Logan logan@vsedev.vse.com VSE Software Development Lab uucp: ..!uunet!vsedev!logan (703) 329-4654 inet: logan%vsedev.vse.com@uunet.uu.net