regex help

Matrix Mole matrixm at gmail.com
Wed Dec 19 22:59:06 MST 2007


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

I've a quik question about doing some regex work. If I have a file that
has the same sequence of character in it (in my example, the path to my
home directory /home/matrixm) and I want to change only the second
occurrence of the path, how would I go about specifying that particular
one to manipulate? If it helps any, I'd like to know the regex that'd be
necessary in either vi or sed (so far to me it seems both use almost
identical regex). So for example, let's say I have a file that has 30-40
lines that look like this:

{some text} /home/matrixm {more text} /home/matrixm {even more text}

and I want to add onto the path of the second path so that instead it
looks like this:

{some text} /home/matrixm {more text} /home/matrixm/tmp {even more text}

I know that a switch command can do it
(s:/home/matrixm:/home/matrixm/tmp:) but I don't know how to force regex
to only work on the second occurrence of the pattern match.

Matrix Mole
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHagSqNtosHRPp48MRAiXhAJ47dZYAmDxL7ATSY49vmehffQ+xhgCePoPz
Ep54ZaCZVrQ8LDUZc5bHonY=
=ajOb
-----END PGP SIGNATURE-----


More information about the PLUG-discuss mailing list