digi
August 17, 2009, 9:49pm
1
Hello everybody.
I have lines that looks something like this:
<done16=""118"" done18=""$ title=""thisisatitle"" href=""/JoeBanana" alt=""Joe""><done16=""118"" done18=""$ title=""thisisatitle"" href=""/GeraldGiraffe" alt=""Gerald"">
What kind of SED command would I need to use to extract into this format:
JoeBanana
GeraldGiraffe
I really should learn but it is getting late and I am getting tired. Anyone that helps me out will have my undying gratitude.
G'night
xx='<done16=""118"" done18=""$ title=""thisisatitle"" href=""/JoeBanana" alt=""Joe""><done16=""118"" done18=""$ title=""thisisatitle"" href=""/GeraldGiraffe" alt=""Gerald"">'
echo $xx | sed 's~^[^/]\+/\([^"]\+\)".*/\([^"]\+\).*$~\1\n\2~
digi
August 18, 2009, 1:46am
3
Thanks edidataguy ! Running that one in my terminal just jumps a line, and gives me a blinking prompt. I will check further.
So what if the original line changes ? What is the syntax to only capture what comes after href="" and before the next " ? Like in the previous example:
href=""/JoeBanana"
It is supposed to do exactly what you asked for.
Output:
JoeBanana
GeraldGiraffe
Sorry, I think I missed a quote at the end.
Trhy this:
echo $xx | sed 's~^[^/]\+/\([^"]\+\)".*/\([^"]\+\).*$~\1\n\2~'
digi
August 18, 2009, 8:37pm
5
hey edidataguy
You're my hero. That did it. Thanks !