I attempting to print all data between double quotes (sampleField="sampleValue"
), but am having trouble to get awk
and/or sub
/gsub
to return all instances of data between the double quotes. I'd then like to print all instances on the respective lines they were found to keep the data together.
Here is a sample of the input.txt
file:
deviceId="1300", deviceName="router 13", deviceLocation="Corp"
deviceId="2000", deviceName="router 20", deviceLocation="DC1"
The output I'm looking for is:
"1300", "router 13", "Corp"
"2000", "router 20", "DC1"
I'm having trouble using gsub to remove all of the data between a ,
and =
. Each time I've tried a different approach, it always just returns the first field and moves onto the next line.
UPDATE:
I forgot to mention that I won't know how many double quote encapsulated fields will be on each line. It could be 1, 3, or 5,000. Not sure if this affects the solution, but wanted to make sure it was out there.