[Cialug] Regular Expression for Pathnames

Todd Walton tdwalton at gmail.com
Mon Nov 24 10:23:07 CST 2014


If I have a text file full of pathnames, like:

/var/log/folder1
/var/log/folder2
/home/todd/mydir
/var/log/folder1/fileh
/var/log/folder1/foldersub/fileh

...etc, what's the regular expression to find where a string has exactly
two (or however many) forward slashes to the left of it?  I have a 360,000
line list of path names, and I'd like to find where a certain string falls
early in the path.  I'm really only interested in paths where it's in the
top three or four directories.

--
Todd


More information about the Cialug mailing list