Skip to content

Instantly share code, notes, and snippets.

@toddlers toddlers/password.rb

Last active Dec 18, 2015
What would you like to do?
passwd file parsing
# On a system the /etc/passwd has entries with duplicate uids, can you write a python program to print
# the users with duplicate uids.
# User x,y,z duplicate uid 10001 on line 4,7,8
# User x,x duplicate uid 10001 on line 4,10
# This is the initial need to update this
require 'pp'
z = {}"passwd","r").each do |line|
lsp = line.chop.split(":",4)
z[lsp[0]] ||=0
z[lsp[2]] ||=0
z[lsp[0]] = z[lsp[0]] + 1
z[lsp[2]] = z[lsp[2]] + 1
z.each_key do |m|
if z[m] >= 2
puts "#{m} occurred #{z[m]} times"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.