On Wed, Nov 29, 2000 at 11:58:02PM -0700, SoloCDM <[EMAIL PROTECTED]> wrote:
| I don't know why, but information piped into a while loop is processed
| v-e-r-y v-e-r-y slowly.  The following is a simple test bash script
| and it took a day to complete one pass through 2.9Gbs of files:
| 
| #!/bin/sh
| #
| 
| find / -xdev -fstype ext2 -type f -printf %h/%f?n | sed 's/\?n/\
| /g' | (
| while read MLINE
| do
|   echo "${MLINE}" | sed '/[Gg][Aa][Mm][Ee]/!d'
| done)
| 
| 
| The find and sed commands on their own produce the information out to
| the screen in no time at all.

That's because you're invoking a new "sed" for EVERY line in the file.
Very very expensive.

Try this:

        find / -xdev -fstype ext2 -type f -printf %h/%f?n | sed 's/\?n/\
        /g' | sed '/[Gg][Aa][Mm][Ee]/!d'

or if you truly feel some need to reimplement "cat" with "while":

        find / -xdev -fstype ext2 -type f -printf %h/%f?n | sed 's/\?n/\
        /g' | while read mline
              do  echo "$mline"
              done | sed '/[Gg][Aa][Mm][Ee]/!d'

Stylistic note: UPPERCASE is reserved for exported variables. This lets
you know at a glance whether you're looking at a script private
variable or a public on, hence the use of $mline instead of $MLINE
above.

Cheers,
-- 
Cameron Simpson, DoD#743        [EMAIL PROTECTED]    http://www.zip.com.au/~cs/

Hit the button Chewie!  - Han Solo



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to