Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unix script to parse password file information

Posted on 2007-03-29
2
Medium Priority
?
213 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 1000 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 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