Can VI Do This?? Delete before a character in text - Maybe advanced.
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What I want to know is, is there a command that will go through the entire list (over 1000 lines) and delete all characters before the @ symbol? Since they are of different lengths, I can't do a simple search and delete/replace. Anyways, I don't know if it's possible, but if it is, I imagine this would be the place for the answer. Google didn't provide me with a definitive answer, so I thought I'd check here. Thank you in advance!
Are you using vi or vim? Vim might have a magic setting, in which case you don’t need to escape the @ at all just plain:
Code:
:%s/^.*@//
P.S. what’s Scine?
I'm using vi. I tried your code, and it did work somewhat. It brought my email list from blah@microsoft.com to microsoft.com. However, I found a bit of tinkering with your code and got it to work. I used this and it worked perfectly.
Thank you very much for the info! Although I must admit, my "sed" abilities aren't where I'd like them to be. I've been running linux for the better part of a few years now, and I'm comfortable with many aspects of it, I must admit that I'm not too familiar with some more popular parts such as sed and awk. But I did notice this particular bit of knowledge helped me out in another area of my project. Thank you very much!
As a side note, to do the opposite, that is to delete everything past a certain character, I used %s/com./com That would replace blah@microsoft.com=username@#$@#$ with blah@microsoft.com It was a part of a project I'm working on, but thought I would mention it to help other people out.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.