Article View: comp.unix.shell
Article #1268piping into read in ksh
From: Wm E Davidsen Jr
Date: Fri, 28 Sep 1990 19:15
Date: Fri, 28 Sep 1990 19:15
28 lines
1406 bytes
1406 bytes
This saved me a lot of time when I found it. Works in ksh, someone
could let me know if it works in bash.
#!/bin/ksh
# This is a demo of piping stuff into read to break it into parts
# using ksh piping a command into read. ksh doesn't use a subshell for
# this, so the values read are preserved.
#
# this is often done with set, which messes up the arguments
# this is a demo of copying news articles and concatenating several
# in some cases, using the number of the first article as the
# destination filename. The names are fixed because (a) you normally
# do this interractively, and (b) it's only a demo.
for n in 101 "102 105 117" 200 212 "214 238 261" 302
do
echo $n | read first1 rest
echo "(cd /news-spl/comp/misc;cat $n) > myrefs/$first1"
done
# author: Bill Davidsen (davidsen@crdos1.crd.ge.com)
--
bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
VMS is a text-only adventure game. If you win you can use unix.
Technical Details
Message-ID:
<2704@crdos1.crd.ge.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!crdgw1!crdos1!davidsenShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.unix.shell Subject: piping into read in ksh Message-ID: <2704@crdos1.crd.ge.COM> Date: 28 Sep 90 19:15:25 GMT Reply-To: davidsen@crdos1.crd.ge.com (bill davidsen) Organization: GE Corp R&D Center Lines: 28