Nerdrium Home



Web Design

Case Mods





My Blog




grep for Social Security Numbers

by Michael Greifenkamp (November 28th, 2007)

At work we have a big push now to scan computers for social security numbers so that we can remove them.

Campus is using a program called "Firefly" to do this on Windows machines.

They have a version for *nix, but it doesn't work quite so well and returns a lot of false positives.

Why not just use grep?

grep '[0-9]\{3\}-[0-9]\{2\}-[0-9]\{4\}' -lr homedir

The big regular expression looks for anything from 000-00-0000 to 999-99-9999. The "-l" (lower-case L) tells it to just list the path and file when it finds a match. The "-r" tells it to recursively search through the entire directory.

So if you run that against a user's home directory, it should list the path of every possible file.

Warning: It might take a while....