![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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. |
||||
| Google The UNIX and Linux Forums |