Solved

awk question

Posted on 2011-02-16
4
315 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

749 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