Solved

Unix script to parse password file information

Posted on 2007-03-29
2
210 Views
Last Modified: 2013-12-26
I am trying to create a script that will pull information from the comment field in the password file, What I want to do is:
for every entry in "ls /home"  I want to get the first initial and the last name from the First Last name entry in the comment field of the password file. The username would work in most cases but in some cases the username is truncated to 8 char, so for that reason I need to get this information.

 jalberso:x:1002:1000:Jaskson Alberson:/home/jalderso:/usr/bin/bash

so in a case like the above example, I want the output of jalberson
0
Comment
Question by:aapl
[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 Comments
 
LVL 6

Accepted Solution

by:
psv1973 earned 250 total points
ID: 18822961
try
to get the first initial
cut -f5 -d: /etc/passwd|cut -c 1
to get the lasst name:
cut -f5 -d: /etc/passwd|cut -f2 -d' '

Maybe not the most efficient way of doing this ( you would probably have to use awk or so but it's clear and it'll work
0
 

Author Comment

by:aapl
ID: 18823064
Yea, that's exactly what I needed, yea the awk portion I already had down, it was the cut that I was stumbling on....


Thanks!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
while loop over for loop 7 116
bigDiff challenge 17 135
unix example issues 18 106
Is there a simple front-end menu system. 9 122
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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