Link to home
Start Free TrialLog in
Avatar of d_asselin
d_asselinFlag for Canada

asked on

awk question

Hi all

    I have to extract field 2 from a /etc/shadow file  were the field
Hash filed doesn’t begin with  ($) character  I know how to
Extract the fiel in question bu not when I want to exlude
All the lines were filed 2 begins with $ in the example
Below I want only users 4 5 6

cat /etc/shadow | awk   'BEGIN {FS=":"} {print $1 ,$2}'

user1: $1$fzNYJ5hW$47JQKHHa7uYHH8SqpUwH3/
user2: $1$HjJNobM9$ZHeda26/JYXJlCUgkehW60
user3: $1$XivDPT4M$fHVwDz3UR3cIBfYaEA8jT1
user4:1VI1N2Yi3R3EI:14495::::::
user5:qcD/yKtWISo12:13451::::::
user6:T4oMaMD.tBqOs:11426::::::
Avatar of Justin Mathews
Justin Mathews

cat /etc/shadow | awk   'BEGIN {FS=":"} index($2, "$") {print $1 ,$2}'
Avatar of d_asselin

ASKER

Not there yet

   I need the lines that field $2 doesn’t begin with $
With this line I get all the lines that begin with $

ASKER CERTIFIED SOLUTION
Avatar of Justin Mathews
Justin Mathews

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is perfect
 Dan