PDA

View Full Version : kornshell script


BerksWebGuy
3-3-05, 10:48 AM
I'm kicking out a log file with condition codes (although there's alot of info in between in the logs, the condition code comes at the end of each process).
So it would be something like:

job 1 started
job 1 cond code 0
job 2 started
job 2 cond code 7
job 3 started
job 3 cond code 0

I know I can grep for "cond code" and get all condition codes, but how would I only pull out condition codes != 0 ?? There are tons of error codes, so I wouldn't want to look for a specific error code...I only want to see cond code != 0 .

Any ideas?

BerksWebGuy
3-3-05, 12:36 PM
Nevermind...got it. In case anyone else wondering:

grep "cond code" file.log | grep -v "cond code 0"

extras
3-3-05, 01:32 PM
I didn't usderstand your question, but now I do.

This will do it in one step, if the cond code is one digit.
grep 'cond code [1-9]' file.log

If there are two, three, or more digits, this will get any code that doesn't start with 0.
grep 'cond code [1-9][0-9]\{0,3\}' file.log

BerksWebGuy
3-3-05, 02:14 PM
Hmm...have to try that one out too.

Thanks.