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

  • SEARCH
  • Home
  • 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 8767751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:53:49+00:00 2026-06-13T16:53:49+00:00

I have a file with different lines, among which I have some lines like

  • 0

I have a file with different lines, among which I have some lines like

173.194.034.006.00080-138.096.201.072.49934

the pattern is 3 numbers and then a dot and then 3 numbers and then a dot, etc.

I want to use awk, grep, or sed for this purpose. How do I express this regular expression?

  • 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-13T16:53:50+00:00Added an answer on June 13, 2026 at 4:53 pm

    Assuming you want to get lines with 1 series like 123. exists, do

     grep '[0-9][0-9][0-9]\.' file > numbersFile
    

    If you want 2 series like 123.345., then do

     grep '[0-9][0-9][0-9]\.[0-9][0-9][0-9]\.' file > numbersFile
    

    etc, etc.

    Each [0-9] means match only one occurance of characters in the range between 0-9 (0,1,2,3,4,5,6,7,8,9).

    Because the ‘.’ char has a special meaning in a normal grep regexp, you nave to escape it like \. to indicate “Just match the ‘.’ char (only!) 😉

    There are fancy extensions to grep that allow you to specify the pattern once, and include a qualifier like {3} or sometimes \{3\} (to indicate 3 repetitions). But this extension isn’t portable to older Unix like Solaris, AIX, and others.

    Here’s a simple test to see if your system supports qualifiers. (Super Grep-heads are welcome to correct my terminology :-).

       echo "173.194.034.006.00080-138.096.201.072.49934" | grep '[0-9]\{10\}\.'
       echo "173.194.034.006.00080-138.096.201.072.49934" | grep '[0-9]\{2\}\.'
    

    The first test should fail, the 2nd will succeed if your grep supports qualifiers.

    It doesn’t hurt to learn the long-hand solution (as above), and you can be sure this will work with any grep.

    IHTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a head file which I am using for a few different pages.
I have a csv file from which I have to populate different tables in
Do I have to put every file in a different folder? like: about-us/about-us.php profile/profile.php
I have some files in IsolatedStorage in my application. The file types are different,
In short, I have a 20,000,000 line csv file that has different row lengths.
I have a file in a different folder I want to rename in perl,
I have a text file with several different sections. Each section has a header
so i have a .js file that 2 different jsp pages call. .js file
I have a log file containing statistics from different servers. I am separating the
I have a solution file with has more than 30 projects in it. Different

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.