Using BaCon with some shell commands (a total novice in the scripting department!)...
I'm trying to parse a dynamically generated (aspx) html file to get at data stored in a table.
First I'm using wget with a custom-built url to get the page to a local file (page.txt). Next I'm using grep like this to just get the lines containing data...
SYSTEM "grep '<tr class=\"aclass\">' page.txt > data.txt"
Then I'm stepping through the lines in data.txt and getting the information between the <td></td> tags.
Ir works great except that the first line contains a single record AND lots of stuff before it (the table tags, table headers etc).
My question therefore: is it possible for grep to return only the contents of the line after the match rather than the whole line? For example, if the whole line was like this;
<tr class=\"aclass\"><td>some data here</td></tr>
Can grep return:
<td>some data here</td></tr>
Ideally I'd like to do this in one line rather than execute a separate script
TIA
Paul
Can grep do something like this?
PaulR,
You can do this-
"Grep -o target.*" matches the target only and .* returns the rest of the line.
Regards,
s
You can do this-
Code: Select all
echo '<tr class=\"aclass\"><td>some data here</td></tr>'|grep -o '<td>.*'
<td>some data here</td></tr>
Regards,
s
grep has as many linux tools the --help or -h option .Can grep return:
<td>some data here</td></tr>
This would show
option .-o, --only-matching show only the part of a line matching PATTERN
Code: Select all
SYSTEM "grep -o '<tr class=\"aclass\">' page.txt > data.txt"
PaulR,
You could code it all in Bacon using just one system call to wget. Vovchik has coded Yweather which parses xml data all written in bacon basic for example.
http://murga-linux.com/puppy/viewtopic. ... h&id=63295
Regards,
s
You could code it all in Bacon using just one system call to wget. Vovchik has coded Yweather which parses xml data all written in bacon basic for example.
http://murga-linux.com/puppy/viewtopic. ... h&id=63295
Regards,
s