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 617589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:27:08+00:00 2026-05-13T18:27:08+00:00

I was wondering if, with egrep ((GNU grep) 2.5.1), I can select a part

  • 0

I was wondering if, with egrep ((GNU grep) 2.5.1), I can select a part of the matched text, something like:

grep '^([a-zA-Z.-]+)[0-9]+' ./file.txt

So I get only the part which matched, between the brackets, something like

house.com

Instead of the whole line like I usually get:

house.com112

Assuming I have a line with house.com112 in my file.txt.

(Actually this regular expression is just an example I just want to know if I can print only a part of the whole line.)

I do know in some languages, such as PHP, Perl or even AWK I can, but I do not know if I can with egrep.

Thank you in advance!

  • 1 1 Answer
  • 1 View
  • 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-05-13T18:27:08+00:00Added an answer on May 13, 2026 at 6:27 pm

    Use sed to modify the result after grep has found the lines that match:

    grep '^[a-zA-Z.-]+[0-9]+' ./file.txt | sed 's/[0-9]\+$//'
    

    Or if you want to stick with only grep, you can use grep with the -o switch instead of sed:

    grep '^[a-zA-Z.-]+[0-9]+' ./file.txt | grep -o '[a-zA-Z.-]+'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wondering how I can send a DELETE instead of POST/GET etc with ASIHTTPRequest. Thanks!
Wondering if someone can answer something that has stumped me. I have a Timer
Wondering if there is any Text to Speech software available as a plug in
Wondering if I need to do something in my swf to be able to
Wondering if anyone can help me with this annoying but trivial (in terms of
Wondering if there's any not-too-hard way to edit non-form text in html 4. I
Just wondering if a .NET app can be compiled down to native machine code
Wondering if anyone can help me understand how the localisation works with keywords. I
Wondering if anyone here can offer any insight into the ups/downs of using the
Wondering if I'm barking up the wrong tree. I'd like a recursive function to

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.