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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:57:42+00:00 2026-06-08T19:57:42+00:00

How can I remove the beginning of a word using grep? For example, I

  • 0

How can I remove the beginning of a word using grep? For example, I have a file that contains this:

www.abc.com

I only need the this part:

abc.com

Sorry for the basic question, but I have no experience with Linux.

  • 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-08T19:57:43+00:00Added an answer on June 8, 2026 at 7:57 pm

    You don’t edit strings with grep in Unix shell, grep is usually used to find or remove some lines from the text. You’d rather use sed instead:

    $ echo www.example.com | sed 's/^[^\.]\+\.//'
    example.com
    

    You’ll need to learn regular expressions to use it effectively.

    Sed can also edit file in-place (modify the file), if you pass -i argument, but be careful, you can easily lose data if you write the wrong sed command and use -i flag.

    An example

    From your comments guess you have a TeX document, and your want to remove the first part of all .com domain names. If it is your document test.tex:

    \documentclass{article}
    \begin{document}
    www.example.com
    example.com www.another.domain.com
    \end{document}
    

    then you can transform it with this sed command (redirect output to file or edit in-place with -i):

    $ sed 's/\([a-z0-9-]\+\.\)\(\([a-z0-9-]\+\.\)\+com\)/\2/gi' test.tex 
    \documentclass{article}
    \begin{document}
    example.com
    example.com another.domain.com
    \end{document}
    

    Please note that:

    • A common sequence of allowed symbols followed by a dot is matched by [a-z0-9-]\+\.
    • I used groups in the regular expression (parts of it within \( and \)) to indicate the first and the second part of the URL, and I replace the entire match with its second group (\2 in the substitution pattern)
    • The domain should be at least 3rd level .com domain (every \+ repition means at least one match)
    • The search is case insensitive (i flag in the end)
    • It can do more than match per line (g flag in the end)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I remove www, http://, https:// from strings using Ruby? I tried this
I can currently remove the last line of a text file using: var lines
I have a column named streetaddress that contains <Street Number> <Street Name> for example:
One can remove all calls to printf() using #define printf . What if I
I am looking for an API that can remove bundle items added in a
Is there anyway or any addin for VS2010 that can remove all the comments
I'm in need of a regular expression that can remove unnecessary/extra parenthesis in a
I was wondering if when using the datagridview control you can remove the thing
How can I remove all white space from the beginning and end of a
I have the following script (modified to remove any private information). -- This line

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.