Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

awk question

Posted on 2011-02-16
4
Medium Priority
?
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Justin Mathews
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:
Justin Mathews earned 2000 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project

722 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