[OT] writing filters in sh
Chip Camden
sterling at camdensoftware.com
Thu Oct 28 20:52:33 UTC 2010
Quoth John Levine on Thursday, 28 October 2010:
> >I was hoping for a generalized, simple idiom for this, rather than
> >needing to implement it myself, for demonstration purposes
>
> ----------------------------------------
> #!/bin/sh
>
> cat "$@" |
> while read x
> do
> echo "I saw $x"
> done
> ----------------------------------------
>
> Sheesh.
>
> R's,
> John
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
<stage_direction>Smacks forehead as if starring in a V-8 commercial</stage_direction>
And of course, if the script does input in more than one place, you can
enclose the entire section in parentheses after the pipe:
cat "$@" | (
read x
...
read y
...
select ans in a b c; do break; done
)
--
Sterling (Chip) Camden | sterling at camdensoftware.com | 2048D/3A978E4F
http://camdensoftware.com | http://chipstips.com | http://chipsquips.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20101028/101a5a2a/attachment.pgp
More information about the freebsd-questions
mailing list