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?
without wishing to be facetious - Passwd::Unix is probably your best bet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With