I know that in sh you can get the contents out of files specified as
command line arguments:

    while read data; do
      echo $data
    done <$@

I know you can also get the contents of files from pipes and redirects:

    while read data; do
      echo $data
    done

In Perl, you can use a single construct to do both and, unlike the first
sh example, it can also take multiple filenames as arguments and
effectively concatenate their contents:

    while (<>) {
      print $_;
    }

I'm not exactly an *expert* in sh, in part because when things start
getting "interesting" while I'm writing shell scripts I tend to just use
a more robust language like Perl.  Please let me know if there's some way
to use a simple idiom like the Perl example to get the same results in
sh.

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]

Attachment: pgpIHWHNamLxY.pgp
Description: PGP signature

Reply via email to