I am looking for a way to extract strings from a file using bash, and append them to another file. The file in question contains data with the following format:
Data="/dataset/0001" a bunch of random stuff I don't need Data="/dataset/0002" more random stuff Data="/dataset/0003"
et cetera.
I am looking to extract and return the strings between the double quotes (ie, /dataset/0001
, /dataset/0002
, /dataset/0003
, etc.).
Any suggestions on how to go about doing this?
As a follow up question, it would be super neat to be able to prepend a constant string (for example, /home/user
) before each returned value (ie, /home/user/dataset/0001
, /home/user/dataset/0002
, /home/user/dataset/0003
, etc.).
Thanks for any suggestions on this.
For instance, I can see what is happening with the wildcard (*) before the double-quote (include everything up to and including the final double-quote), but what is happening inside of the square brackets
[^"]
?Thanks again, I really appreciate this (and everyone else who contributed).
– jon danniken Dec 22 '19 at 01:03