d_asselin
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$47JQKHHa7uYHH8 SqpUwH3/
user2: $1$HjJNobM9$ZHeda26/JYXJlC UgkehW60
user3: $1$XivDPT4M$fHVwDz3UR3cIBf YaEA8jT1
user4:1VI1N2Yi3R3EI:14495: :::::
user5:qcD/yKtWISo12:13451: :::::
user6:T4oMaMD.tBqOs:11426: :::::
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$47JQKHHa7uYHH8
user2: $1$HjJNobM9$ZHeda26/JYXJlC
user3: $1$XivDPT4M$fHVwDz3UR3cIBf
user4:1VI1N2Yi3R3EI:14495:
user5:qcD/yKtWISo12:13451:
user6:T4oMaMD.tBqOs:11426:
cat /etc/shadow | awk 'BEGIN {FS=":"} index($2, "$") {print $1 ,$2}'
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 $
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is perfect
Dan
Dan