This is a kind of bizarre problem..
I have a list of words between html tags, each separated by a line, with some whitespace on the left, like so:
<td>word</td>
<td>anotherWord</td>
...
I want to extract the words from the list and not the tags, so I use:
temp=$(printf "%s" "$temp" | egrep '[....]')
Just to clarify, "temp" is the input to be searched. (I am doing this in a bash script, and I stored the input in variable temp). The "..." is a list of characters, since the words I'm trying to extract only use certain characters.
Whenever the grep finds a match, it outputs the word along with the html tags on either side! This only happens with a match, because I tested this by having the regex parameter be gibberish, like '09680876' - it had no matches in the temp file, and grep outputted nothing.
I also tried to use a specific word that I knew was a match as the regex parameter, like so:
.... | egrep 'hanai')
where I knew 'hanai' was a definite match in the sample text. This resulted in grep outputting
<td>hanai</td>
I am completely stumped and haven't been able to find solutions online. Would appreciate someone pointing out the obvious mistake I'm making.
egrepis deprecated. Usegrep -Einstead.