On Wed, 19 Dec 2007 10:47:04 -0800 (PST),
cozzmo1@[EMAIL PROTECTED]
wrote:
>Perhaps someone could help with this.
>This script times out.
>
>
>#!/bin/bash
>cat ~/$1 | while read line
>do
>if [[ "$line" != /*/*/**Closed* && "$line" != "" && "$line" != *Auto?
>Closed* ]]
> then
>{
>if [[ "$line" == [1-6][0-9][0-9][0-9][0-9]\,*[a-z,A-Z]* ]]
>then
>{
>read ticket date time <<EOF
>$(echo "$line" | nawk 'BEGIN { FS = "," } ; { print $1, $6, $7 }')
>EOF
>echo "$ticket" "$date" "$time" "Opened"
>}
>elif [[ "$line" == \*\*\**Not?Approved* ]]
>then
>{
>echo "$line" | nawk '{ print "$ticket" " " $4 " " $5 " " "Not-
>Approved" }'
>}
>elif [[ "$line" == \*\*\**Picked?Up* || "$line" == \*\*\**Complete*
>|| "$line" == \*\*\**Approved* ]]
>then
>{
>echo "$ticket" "$line" | nawk '{ print $1 " " $5 " " $6 " " $8 }'
>}
>fi
>}
>fi
>done
>
>---------
>Output: (note yak1 is a very huge file, and I am just trying to get
>the facts out.)
>
>$ temp2 yak1
><snip>
>32626 2007-09-26 10:57:00 Opened
>32626 09-26-2007 12:23 Picked
>32626 09-26-2007 12:47 Approved
>32626 09-27-2007 01:51 Complete
>32627 2007-09-26 11:16:00 Opened
>32627 09-26-2007 11:30 Picked
>32627 09-26-2007 11:30 Approved
>32627 09-26-2007 11:41 Complete
>32628 2007-09-26 11:20:00 Opened
>32628 09-26-2007 11:29 Picked
>32628 09-26-2007 11:29 Approved
>32628 09-26-2007 11:46 Complete
><output ends here>
>but the file hasn't even been half parsed, if I pipe this to a file,
>then it ends sooner (32635).
>
>This seems to have started after I added these items in order to print
>from the variables instead of just rendering straight to print.
>read ticket date time <<EOF
>EOF
>echo "$ticket" "$date" "$time" "Opened"
>
>I am sure it has nothing to do with the input file.
>but don't know why it hangs.
>maybe there is a buffer that fills up because of the variables??
>
>Thanks,
>crzzy1
I would advise te rewrite it in 100% awk.
The jumping between bash and awk costs time. Forking,
opening file handles and such isn't for free.
--
( Kees
)
c[_] Eat, drink and be merry, for tomorrow they may make it illegal.
(Stanislaw Gierlicki) (#38)


|