[wplug] Line-by-line input from stdin, from a bash script ?

Dave Ostroske eksortso at gmail.com
Mon Oct 14 13:04:11 EDT 2013


Bash doesn't have a lot of full line processing capabilities. You might get
some things with "read" if you use the right options, but "read" will
definitely chop end-of-line spaces if you let it.

Best thing to do is hand off your line processing to other tools. I'm a fan
of awk and sed, but YMMV. Perl is good with a lot of this kind of stuff. I
love Python, others adore Ruby.

That's a very broad answer, but it was a very broad question.

-- Dave Ostroske
On Oct 14, 2013 12:49 PM, "Pat Barron" <pat at lectroid.com> wrote:

> Does anyone have any favorite methods of doing "line at a time" input
> from stdin, using a bash script?  Is "read" reliable enough to use for
> this?  Will it do antisocial things to me, like trimming trailing
> whitespace from lines it reads?  (Ultimately, what I want is the exact
> input, byte-for-byte, that was read from stdin...). I've only ever used
> it, really, for prompting for stuff interactively, never tried to use it
> from a script.  Is there some other way I'm not aware of?
>
> --Pat.
>
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
>


More information about the wplug mailing list