![]() |
Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
On Tue, 2 Sep 2003, Dan Barrett wrote: > On Tuesday 02 September 2003 15:35, Derek Martin wrote: > > > If the file contains more than one word per line (such as a dictionary > > with definitions), this won't work. It can still be done, but you'd > > need a lot more logic. AFAIK, there's no way to do that with a single > > regular expression, or even a simple pipeline. > > > In this case, I'd use sed to change the whitespaces into newlines: > > cat file_with_multiple_words_per_line | sed -e 's/ /\n/g' | <grep exp> Or use `fmt` with a very short line length target to force each word to take up one line: fmt -1 file | grep foo (I got into this habit when I started noticing that some versions of sed don't seem to like having newline metacharacters in the pattern or sub.) -- Chris Devers cdevers at pobox.com http://devers.homeip.net:8080/resume/ foolproof, adj. (Of a system) inaccessible by the USER. Compare INTUITIVITY. -- from _The Computer Contradictionary_, Stan Kelly-Bootle, 1995
![]() |
|
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |