Search code examples
htmlregexlinuxbashcut

Grep linux regular expression


Hi everyone I have an issue..

I'm trying to wrote regexp but I already have no suggestions..

I have some file with html source.

</tr>
    <tr anotherID="433943" sometext="">
    <td>
    .a lot of source
    .a lot of source
    .a lot of source
    .a lot of source
    .a lot of source
    </tr>
    <tr WANTED_ID="361112" sometext="">
    <td>
    <some title text or anything></span>
    </td>
    <td>
    thisisnamewhichInow
    .a lot of source
    .a lot of source
    .a lot of source
    .a lot of source
    .a lot of source

So. I want to paste WANDED_ID into my variable. But I know only "thisisnamewhichInow".. I can use any utility in bash. example 'cut'.


Solution

  • I think this will get you what you want, the last id before your known string

    myvariable=$(perl -e'$/=undef;<>=~/.*id="(\d+)".*?bgMiner.vminer/s;print"$1\n"')