On 3 December 2014 at 11:53, Steve Engledow steve@offend.me.uk wrote:
Would summat like this do?
echo $(basename -s .xls $myfile): $(xls2csv $myfile | grep -oE '"Location:([^"]+)"' | cut -d ':' -f 2)
Yes, for the example case (which is all I asked, so well done!), however I'm finding that the not all fields are formatted the same (eg ":" might be "-"), so something based on selecting a specific match from a regex would be better.
I've got some way closer using gawk (note: not awk) and "match()", however I have cme up against another problem: sometimes the fied will contain carriage returns: "foo", "bar", 123, "Location: This is a location", "etc" .. and my pattern matching in gawk is obviously line based.
Of-course maybe I'm looking at this the wrong way; I'm sure there are more flexible XLS parsers that could be told to just give me what ever is in a certain cell (that looks fairly consistent so far, but I'll no doubt find out otherwise soon), and maybe even search the XLS file for a matching cell and extract that. But I have nothing yet that will do that, Google here I come...
Mark