Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8642639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:49:34+00:00 2026-06-12T11:49:34+00:00

So on the command line in linux I am trying to search some HTML

  • 0

So on the command line in linux I am trying to search some HTML code and print just a dynamic part of the code. For example this code

<p><span class="RightSideLinks">Tel: 090 97543</span></p>

I would just want to print 97543 not the 090. The next time I search the file the code might have changed to

<p><span class="RightSideLinks">Tel: 081 82827</span></p>

And I just want the 82827. The rest of the code stays the same just the phone numbers change.

Can I use grep to do this?
Thanks

Edit:

Would it be possible to use it on this code too?

<tr class="patFuncEntry"><td align="left" class="patFuncMark"><input type="checkbox" name="renew0" id="renew0" value="i1061700" /></td><td align="left" class="patFuncTitle"><label for="renew0"><a href="/record=p1234567~S0"> I just want to print this part. </a></label>

What changes on that is the record number: p1234567~S0" and the text that I want to print.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:49:35+00:00Added an answer on June 12, 2026 at 11:49 am

    One way using GNU grep:

    grep -oP '(?<=Tel: .{3} )[^<]+' file.txt
    

    Example contents of file.txt:

    <p><span class="RightSideLinks">Tel: 090 97543</span></p>
    <p><span class="RightSideLinks">Tel: 081 82827</span></p>
    

    Results:

    97543
    82827
    

    EDIT:

    (?<=Tel: .{3} ) ## This is a positive lookbehind assertion, which to be
                    ## interpreted must be used with grep's Perl regexp flag, '-P'.
    
    Tel: .{3}       ## So this is what we're actually checking for; the phrase 'Tel: '
                    ## followed by any character exactly three times followed by a 
                    ## space. Since we're searching only for numbers you could write
                    ## 'Tel: [0-9]{3} ' instead.
    
    [^<]+           ## Grep's '-o' flag enables us to return exactly what we want, 
                    ## rather than the whole line. Therefore this expression will
                    ## return any character except '<' any number of times.
    
    Putting it all together, we're asking grep to return any character except '<' 
    any number of times if we can find 'Tel: .{3} ' immediately ahead of it. HTH.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some tests for a C++ command line Linux app. I'd like to
How can I run this on linux command line when my username has an
Does anyone know of a linux-compatible command line html formatter? You know, something where
I am trying to run a .NET command line application in Linux using Mono.
These run on the command line in linux (ubuntu) but when trying to run
I am trying to run some Java code I found on linux. maudecmd =
First, context: I'm trying to create a command-line-based tool (Linux) that requires login. Accounts
I've written a C++ program (command line, portable code) and I'm trying to release
I run several queries from mysql command line on my linux box (Fedora Os).
I am launching a Python script from the command line (Bash) under Linux. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.