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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You don’t edit strings with
grepin Unix shell,grepis usually used to find or remove some lines from the text. You’d rather usesedinstead:You’ll need to learn regular expressions to use it effectively.
Sed can also edit file in-place (modify the file), if you pass
-iargument, but be careful, you can easily lose data if you write the wrongsedcommand and use-iflag.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:then you can transform it with this
sedcommand (redirect output to file or edit in-place with-i):Please note that:
[a-z0-9-]\+\.\(and\)) to indicate the first and the second part of the URL, and I replace the entire match with its second group (\2in the substitution pattern)\+repition means at least one match)iflag in the end)gflag in the end)