Get data from multi lined text file using awk, sed or perl - grep & cut not upto par
I need a loop that pulls out the user name into a variable and then pulls out the LastUpdate field into another variable so I can then perform a comparison against the last update field.
Requirements are AIX tools including AWK, SED and Perl I am writing a script to check AIX users password expiration dates and if they are within the alerting period (ie. 7 days etc) it will email the user. I will release the full script into the public domain once completed. The text file I want to parse is formatted like: Code:
colettel: *Cam |
"awk '/:/ {name=$1} ; /lastu/ {print name $3}' input.file" should get you started (assumes well-formed data). dealing with the colon should be trivial.
|
Cant' we just use a shell script?
Code:
#!/bin/sh |
Code:
awk 'BEGIN { RS = "" } |
Thanks Syg00 hit the nail on the head. I can now parse that output to extract the two variables I require - Username and LastUpdate time!
Thanks Heaps. Thanks to everyone else who gave their input also! |
All times are GMT -5. The time now is 04:27 PM. |