Skip to content

Instantly share code, notes, and snippets.

@jreisinger
Last active July 19, 2019 15:09
Show Gist options
  • Select an option

  • Save jreisinger/2219366 to your computer and use it in GitHub Desktop.

Select an option

Save jreisinger/2219366 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
file = "/etc/passwd"
file_object = open(file, 'r')
shell = {}
for line in file_object:
line = line.strip()
fields = line.split(":")
shell[fields[0]] = fields[-1]
file_object.close()
for user in shell.keys():
print("{0:11} => {1}".format(user, shell[user]))
@mweinelt

Copy link
Copy Markdown

Hey, there are modules for that kind of thing.

See pwd, grp and spwd.

@jreisinger

Copy link
Copy Markdown
Author

Thanks. I was just playing around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment