0

I have inherited about 6 servers (all Debian based), and part of my project over the next year is consolidate everything into one server. There are 6 "domains" running from Samba3 installations, and I'd like to merge them all into the one new server once I get everything sorted out. What I would like is to know if there is a way to load the /etc/passwd file to show just usernames that end in a $, so I know they are a computer name. Once I can get this, I can (hopefully) make a script to add all the machines to the new master, but that's for another question later

Canadian Luke
  • 885
  • 15
  • 44

3 Answers3

1
cat /etc/passwd | grep \$\: | cut -d : -f 1

would be my first attempt.

Sven
  • 98,649
  • 14
  • 180
  • 226
1

Here's how I'd do it:

awk -F: '{print $1}' /etc/passwd | grep '\$$'
1

I think

grep -P '^[^:]+?\$:' /etc/passwd

Is the most concise way to do this.

Edit: Found a more concise way. This will not confuse stray "$:" that exist in GECOS fields, for example.

Matthew Ife
  • 23,357
  • 3
  • 55
  • 72