1 |
Remember my script that sends out HTML emails? Well, that's done, but |
2 |
it's in-efficient. |
3 |
|
4 |
The actual script that parses screen-scrapes. Initial script only went |
5 |
to get the "Last Price" now, I would like to add the "Day Range" |
6 |
|
7 |
last_price() |
8 |
{ |
9 |
value="$(lynx -dump "$url$symbol" | grep 'Last price:' | \ |
10 |
awk -F: 'NF > 1 && $(NF) != "N/A" { print $(NF) }' )" |
11 |
} |
12 |
|
13 |
day_range() |
14 |
{ |
15 |
day_range="$(lynx -dump "$url$symbol" | grep 'Low \& High:' | \ |
16 |
awk -F: 'NF > 1 && $(NF) != "N/A" { print $(NF) }' )" |
17 |
} |
18 |
|
19 |
The above is in-efficient because I need to call the script to get the |
20 |
page 2 times. |
21 |
|
22 |
Doing a |
23 |
|
24 |
lynx -dump "$url$symbol" | egrep -i '(Last Price|Low \& High)'| awk -F: |
25 |
'NF > 1 && $(NF) != "N/A" { print $(NF) }' |
26 |
|
27 |
will work, but then, there will be 2 values associated with it : |
28 |
7.35 |
29 |
7.127 - 7.38 |
30 |
|
31 |
Can anyone help with a better awk script so that each value will be |
32 |
associated with each line? |
33 |
|
34 |
eg: |
35 |
last_price=7.35 |
36 |
day_range=7.127 - 7.38 |
37 |
|
38 |
w/o actually piping the lynx output to a file (actually, that would be |
39 |
the easy way) |
40 |
|
41 |
On the other hand, how does one use awk for multigreps like egrep '(pop| |
42 |
test)' |
43 |
|
44 |
I've tried variation of |
45 |
1. awk "/Low & High/" |
46 |
2. awk "/Low & High/" && /Last/ |
47 |
3. awk '{"/Low & High/" && /Last/}' |
48 |
all of which doesn't work except for No. 1 |
49 |
|
50 |
-- |
51 |
Ow Mun Heng |
52 |
Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM |
53 |
98% Microsoft(tm) Free!! |
54 |
Neuromancer 13:54:21 up 1 day, 4:11, 6 users, load average: 3.66, 2.92, |
55 |
2.71 |
56 |
|
57 |
|
58 |
-- |
59 |
gentoo-user@g.o mailing list |