Tweeted twitter.com/StackUnix/status/892572277069545473
2 added 1 character in body
source | link

I have some data like

<td><a href="data1">abc</a> ... <a href="data2">abc</a> ... <a href="data3">abc</a>

( Would refer to above line as data in code below )

I need data1 in between the fistfirst " and " so I do

echo 'data' | sed 's/.*"\(.*\)".*/\1/'

but it returns me the last string in between " and " always, i.e in this case it would return me data3 instead instead of data1

In order to get data1, I end up doing

echo 'data' | sed 's/.*"\(.*\)".*".*".*".*".*/\1/'

How do I get data1 without this much of redundancy in sed

I have some data like

<td><a href="data1">abc</a> ... <a href="data2">abc</a> ... <a href="data3">abc</a>

( Would refer to above line as data in code below )

I need data1 in between the fist " and " so I do

echo 'data' | sed 's/.*"\(.*\)".*/\1/'

but it returns me the last string in between " and " always, i.e in this case it would return me data3 instead instead of data1

In order to get data1, I end up doing

echo 'data' | sed 's/.*"\(.*\)".*".*".*".*".*/\1/'

How do I get data1 without this much of redundancy in sed

I have some data like

<td><a href="data1">abc</a> ... <a href="data2">abc</a> ... <a href="data3">abc</a>

( Would refer to above line as data in code below )

I need data1 in between the first " and " so I do

echo 'data' | sed 's/.*"\(.*\)".*/\1/'

but it returns me the last string in between " and " always, i.e in this case it would return me data3 instead instead of data1

In order to get data1, I end up doing

echo 'data' | sed 's/.*"\(.*\)".*".*".*".*".*/\1/'

How do I get data1 without this much of redundancy in sed

1
source | link

Sed to print only first pattern match of the line

I have some data like

<td><a href="data1">abc</a> ... <a href="data2">abc</a> ... <a href="data3">abc</a>

( Would refer to above line as data in code below )

I need data1 in between the fist " and " so I do

echo 'data' | sed 's/.*"\(.*\)".*/\1/'

but it returns me the last string in between " and " always, i.e in this case it would return me data3 instead instead of data1

In order to get data1, I end up doing

echo 'data' | sed 's/.*"\(.*\)".*".*".*".*".*/\1/'

How do I get data1 without this much of redundancy in sed