Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Bash script...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 7 Topic 2105 of 2347
Post > Topic >>

Re: Bash script timing out

by Kees Nuyt <k.nuyt@[EMAIL PROTECTED] > Dec 19, 2007 at 09:19 PM

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)
 




 7 Posts in Topic:
Bash script timing out
cozzmo1@[EMAIL PROTECTED]  2007-12-19 10:47:04 
Re: Bash script timing out
Kees Nuyt <k.nuyt@[EMA  2007-12-19 21:19:12 
Re: Bash script timing out
Ed Morton <morton@[EMA  2007-12-19 17:44:46 
Re: Bash script timing out
cozzmo1@[EMAIL PROTECTED]  2007-12-21 08:54:47 
Re: Bash script timing out
Ed Morton <morton@[EMA  2007-12-21 12:34:46 
Re: Bash script timing out
cozzmo1@[EMAIL PROTECTED]  2008-01-03 08:23:56 
Re: Bash script timing out
Ed Morton <morton@[EMA  2008-01-03 18:27:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 7:41:42 CDT 2008.