The format looks like this:
serial user status lastlogin
-->token startdate expdate
For instance, I might have this section of log:
1234 JonDoe Enabled 1/2/3
-->token 1/1/1 3/3/3
1235 Unassigned 0/0/0
-->token 0/0/0 0/0/0
1236 Disabled 1/2/3
-->token 1/1/1 2/2/3
I know that I can grab just the active users with "grep -A1 Enabled",
but what if I want to exclude tokens that are Unassigned, but keep any
other statuses? I would think that "grep -v -A1 Unassigned" would
discard the line with Unassigned and expand the selection to the next
line, but I get everything.
I've been using this command to test the concept: echo -e "a\nb\nc\nd"
|grep -v -A1 b
I would expect that command to return just "a" and "d" but I get "b"
and "c" as well.
Is there a way to do this with grep, or am I trying to hammer a screw?
Would a clever RegEx fix my problem, or should I think about writing
a script to process this log?
Thanks.
Using cut is eeww. Try awk.
sed 's/\n-->/ /' <in_log |grep -v 'username to be rid of' | awk '{print $2}'
Using awk will split on whitespace normally. Then you just need to know what
column number you want to print. Granted it won't work well if you have
conditional columns that occasionally don't have content, or fields with
allowable spaces in them.
--
Steven Critchfield cri...@basesys.com