On Wednesday 01 August 2007 09:35:44 Robert Huff wrote: > (This is probably a FAQ, and I'll take a pointer (or even the > magic words to identify the problem) instead of an answer.) > Let's suppose I have a file FILE, with contents: > > foo > bar grill > baz > > If I do "cat FILE", everything comes out fine. > If, however, I write a script: > > > #!/bin/sh > > for i in `cat FILE` > do > . > . > . > . > done > > $i is set to > > foo > bar > grill > baz > > Is there a way within the script - or, failing that, by > modifying FILE - to not break at the whitespace?
I'm sure someone will give you a more elegant solution, but short of using sed or awk (my preference), this might help: $ cat test.sh #!/bin/sh myloop() { while read line; do echo $line done } cat test.sh | myloop hth... don > > > Robert Huff > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "[EMAIL PROTECTED]" -- Don Hinton <don.hinton at vanderbilt.edu> or <hintonda at gmail.com> Institute for Software Integrated Systems (ISIS), Vanderbilt University tel: 615.480.5667 or 615.870.9728 _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"