cat file | grep "<span class='s-name'>" | awk '/"<span class='s-name'>"/ && /</span>
something about this seems wrong. I mean, other than it's not working.
I also want to put it into a file which I'm pretty sure is just 'filename' at the end.
cat file | grep "<span class='s-name'>" | awk '/"<span class='s-name'>"/ && /</span>
something about this seems wrong. I mean, other than it's not working.
I also want to put it into a file which I'm pretty sure is just 'filename' at the end.
Using GNU grep
Input
$ cat infile
<div class='signer'> <span class='s-name'>Bob Lepine</span> <span class='s-title'>Vice President of Content, FamilyLife</span> </div>
Output
$ grep -Po "(?<=<span class='s-name'>).*?(?=</span>)" infile
Bob Lepine
$ grep -Po "(?<=<span class='s-title'>).*?(?=</span>)" infile
Vice President of Content, FamilyLife
Using xml/html parsers is the proper way to parse xml/html content, xmlstarlet solution:
xmlstarlet sel -t -v "//span[@class='s-name']" yourfile
The output:
Bob Lepine