Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex Verification of Line in /etc/passwd

Tags:

regex

unix

perl

I need to verify an /etc/passwd file is valid, and thought regex would be a good idea to verify the lines that are not comments. How would I verify a line like:

root:*:0:0:System Administrator:/var/root:/bin/sh 

After some research, the 5th field (System administrator) can contain other data like email and address, the second field could contain anything but a :, the last 2 fields are full paths.

Any clues how I would create a regex expression for this?

like image 555
Mike Avatar asked Nov 07 '10 17:11

Mike


1 Answers

without wishing to be facetious - Passwd::Unix is probably your best bet.

like image 161
phatmanace Avatar answered Sep 24 '22 04:09

phatmanace