RE's and grep

Dan Barrett nullpointer at pobox.com
Tue Sep 2 15:44:22 EDT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/VPMWsIjNiQTGkXARAueTAJ4+uIwmQksix0XnYGnjyO3OvZ7MfQCfRVA+
8f/pOywKmsMR3Sknhmjr+4c=
=bi1h
-----END PGP SIGNATURE-----




More information about the Discuss mailing list