twb2005,
You can try something like this;
Code:
awk -F: '{ print $1 }' /etc/passwd
A basic rundown on how it works.
awk bascially scans for patterns and sequences, and then handles the input accordingly.
-F: tells awk what to use as the field seperator. Take the following example of an /etc/passwd file.
Code:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
As you can see, the field seperator in the /etc/passwd file is the semicolon (:). This is what we need to tell awk to use as a seperator.
'{ print $1 }' tells awk to print the first column (The user column).
/etc/passwd is the file we want processed by awk.
This should help get you on your way.
Regards,
-Kristijan