![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Process id's in file names | tekster757 | UNIX for Dummies Questions & Answers | 1 | 03-07-2008 12:29 PM |
| Dowloading a File from FTP Server to a local Server where User Id's are different | ranjith_taurean | Shell Programming and Scripting | 1 | 02-22-2007 07:47 AM |
| Shell script to return all the ID's from file based on the distribution ID search | kumbhatalok | UNIX for Dummies Questions & Answers | 1 | 10-06-2006 12:53 PM |
| User should not be allowed to change passwd | brookingsd | UNIX for Dummies Questions & Answers | 3 | 01-23-2006 12:00 PM |
| Unix user ID's case-sensitive? | dmilleville | UNIX for Dummies Questions & Answers | 3 | 12-14-2003 08:38 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Looking for specific user ID's from the passwd file
Hello,
My issue is that I want to look for specific users that have their first and last initial followed by four numbers. For example: ab1234 I've already got the user ID's out of the passwd file Code:
more passwd | awk -F ":" '{print $1}' > userids
aannnn a=alphabet n=number Thanks in advance! |
|
||||
|
Thanks for the replay. Will that account for all the different userids that fit that pattern I mentioned above?
EDIT: I tried the following: Code:
more passwd | awk -F ":" '{print $1}' | grep -e ^[:alpha:][:digit:]
lp adm and some other users who didn't fit the EXACT pattern I asked for above. I want to be able to list all users that fit the pattern below; aannnn example: ab1234 Last edited by LinuxRacr; 08-24-2007 at 11:29 AM.. |
|
||||
|
Code:
more passwd | awk -F ":" '{print $1}' | egrep '[A-Za-z]{2}[0-9]{4}'
Code:
egrep '^[A-Za-z]{2}[0-9]{4}:' /etc/passwd
|
|
||||
|
Code:
egrep '^[A-Za-z]{2}[0-9]{4}:' /etc/passwd
Yet another method I found: Code:
awk -F: '$1~"^[a-z]{2}[0-9]{4}$"{print $1}' /etc/passwd
Last edited by LinuxRacr; 08-24-2007 at 12:22 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|