Solved

awk question

Posted on 2011-02-16
4
313 Views
Last Modified: 2012-05-11
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::::::
0
Comment
Question by:d_asselin
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:jmatix
ID: 34907970
cat /etc/shadow | awk   'BEGIN {FS=":"} index($2, "$") {print $1 ,$2}'
0
 

Author Comment

by:d_asselin
ID: 34908018
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 $

0
 
LVL 16

Accepted Solution

by:
jmatix earned 500 total points
ID: 34908085
Sorry,

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

Author Closing Comment

by:d_asselin
ID: 34908132
This is perfect
 Dan
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
A short article about problems I had with the new location API and permissions in Marshmallow
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question