Solved

Unix script to parse password file information

Posted on 2007-03-29
2
206 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now