[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
Hello. Does anyone know of a way that I can read *one* char at a time from standard input in bash? I keep writing short (3 line) C programs to do this, but it's a bit annoying having to compile it. I should probably be using regex for this, but I can't work it out and I swear it's much easier just to do it with getchar and loops. I guess the main point is that I want to operate on a stream of chars rather than line by line. Basically, I have a huge block of text with arbitrary newlines (which should be ignored completely- I've used "tr -d '\n'" for this so far), and email addresses scattered all over the place. I want to extract these addresses and print them to standard out. I think the regex for this should be '[a-zA-Z0-9]*@[a-zA-Z0-9]*', but I can't figure out how to get sed or grep (what should I be using for this?) to output just the bit that matches instead of the whole darn line. Any ideas? Thanks in advance. Simon -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html