The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do I pass or read values from file ? nix-kid Shell Programming and Scripting 1 05-20-2008 10:04 AM
How to read values that are passed to the shell function in ksh. prashant43 Shell Programming and Scripting 2 01-22-2008 08:21 AM
read values from ps -ef into variables in ksh? JamesByars Shell Programming and Scripting 8 01-13-2008 05:12 AM
I want to read username and lastupdate only from /etc/security/passwd and write the s me_haroon AIX 0 07-01-2006 01:16 AM
How can I read variable values from file? redlotus72 UNIX for Dummies Questions & Answers 1 03-14-2005 02:38 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-30-2006
Registered User
 

Join Date: Apr 2006
Posts: 18
How do I read username and lastupdate attribute values from /etc/security/passwd

Hi,

How do I read username and lastupdate attribute values from /etc/security/passwd file and write the obtained data to another file. The data in the new file should be in this format as shown:

avins:12345
root:45234
xyza:23423

Plese let me know this ASAP

Thanks,
Haroon
Reply With Quote
Forum Sponsor
  #2  
Old 06-30-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 360
sed "s/^\([^:]*\):[^:]*:[^:]*:\([^:]*\).*$/\1:\2/" /etc/security/passwd
Note: number of [^:]* in the middle of the pattern equals to number of columns separated by ':' you want to skip
Reply With Quote
  #3  
Old 06-30-2006
Registered User
 

Join Date: Apr 2006
Posts: 18
Hi All,
As i asked you in my previous post, I want to read username and lastupdate only from /etc/security/passwd and write the same data to another file:
The data in /etc/security/passwd will be in this form for example:

smith:
password = MGURSj.F056Dj
lastupdate = 623078865
flags = ADMIN,NOCHECK

From this I want username i.e smith and value in lastupdate to be written to another file test.

Note: I should be able to write information of all users to test file in this format
smith:623078865
Reply With Quote
  #4  
Old 07-01-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 360
I hope this will be appropriate:

#!/bin/sh

cat /etc/security/passwd | sed -n '
/^.*:\s*$/ h
/^\s*lastupdate/ {
s/^\s*lastupdate\s*=\s*//
H
g
s/\n//
p
}
' > test

Last edited by Hitori; 07-01-2006 at 11:28 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0