Grep and xml files

sandy_a

Junior Member
Oct 5, 2010
1
0
0
I am writing documents in XML using Arbortext. I would like to make a list of all referenced graphics using grep. Here's what I tried:

* Save the xml file as .txt.
* Grep for file.loc="*" in hopes of finding all strings like this:
file.loc="../graphics/online/image.jpg"
file.loc="../graphics/print/image.eps"

Grep does find all of these references, but it appears to return everything in the line, which includes a whole lot of markup and content that comes before and after the text reference. I believe this is because XML doesn't use line breaks in a meaningful way,

Is there a way to get grep to return only the text string I am specifying?

Any help would be greatly appreciated!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
AFAIK XML doesn't care about line breaks, you can use them if you want but they're not necessary since the tags determine the layout, so just add them when creating the file. If it's being automatically generated by some program like that then you'll need a second app like 'cut' to only give you the parts that you want because I believe grep only works on full lines.