Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
and the space is infront of it in the results also, it's like the results are displayed with a space replacing the first character of all matching results.
Regex are still like magic to me, and I have the hardest time figuring them out. I thought I was getting better, but I guess not. Please if anybody can help that would be great! Thanks in Advance!
I tend to use perl full stop for most things - I doubt if using a perl like regexp in grep would make much difference. Like Tinkster - your grep command works for me. I can only assume there is somthing odd with either the file you are reading from (malformed characters or bad end of lines) or there is somthing wrong with another part of the script you are running this command from.
How are you calling the grep command? From the command line or from within a script? It may help if you post the script (if there is one) and the content of the file you are trying to grep.
I was running grep from the command line. I can't really post the contents of the file cause it is a huge file 34meg, it is just an inbox file from netscape, however there are characters in the file, after some of the email address that look like this: ^M I believe that is the windows line break character, but I can't see how that would influence it. The lines aren't that complicated, but I have tried this on another file and had it work also, I wonder if I uploaded the file in Binary...hmmm...
Figured it out,
I search and replaced those ^M with \n and it fixed it. Now does anybody know how to have grep return only the exact matches and not the full lines where they match? For example the line is:
AFAIK, Nutscrape uses std mbox format, which means you should be able to do "cat <nutscrape_mbox> | formail -czx From: -s" to get the "from" address for instance.
If you have got to get the 3rd field from a header and know fields are space separated, you could do "cat <nutscrape_mbox> | formail -czx From: -s" | while read i; do i=( ${i} ); printf "%s${i[2]}\n"; done". Arrays count from zero up.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.