Having arguments as follows
There are totally 210 error codes. I have already grep custom logs as follows
checkerr.sh
A awk '$1 == 0 || $1 ==1{print $0}' rep1.txt > success.log
B awk '$1 == 84 || $1 ==85 || $1==86 {print $0}' rep1.txt > MediaErr.log
i need all the other 205 error codes grepped to OtherErr.log excluding the above error codes
OtherErr.log = Alllogs != A && B
any way, thanks with anticipation
Note : A & B indicated here are connectors and not commands
awk '! /^[0-1]$/ && ! /^8[4-6]$/ {print $0}' rep1.txt > OtherErrors.log
Success
hi dan,
rep1.txt
Err Date Time Server Network Dept Usr Pid
1 10/10/2008 00:00:01 Server A Class A 1001 jack 101
6 10/10/2008 00:00:01 Server A Class A 1002 jack 102
85 10/10/2008 00:00:01 Server A Class A 1004 aaa 103
84 10/10/2008 00:00:01 Server A Class A 1001 bbb 104
96 10/10/2008 00:00:01 Server A Class A 1001 jack 151
196 10/10/2008 00:00:01 Server A Class A 1001 jack 161
219 10/10/2008 00:00:01 Server A Class A 1001 jack 106
0 10/10/2008 00:00:01 Server A Class A 1001 jack 201
1 10/10/2008 00:00:01 Server A Class A 1001 jack 202
6 10/10/2008 00:00:01 Server A Class A 1001 jack 109
Category A in red gives output as per the command
A awk '$1 == 0 || $1 ==1{print $0}' rep1.txt > success.log
Category B in red gives output as per the command
B awk '$1 == 84 || $1 ==85 || $1==86 {print $0}' rep1.txt > MediaErr.log
I want rest of all other lines to OtherErr.log and should exclude Cat A & B
The command given by u simply gives output of the whole file rep1.txt
awk '! /^[0-1]$/ && ! /^8[4-6]$/ {print $0}' rep1.txt > OtherErrors.log
output received
1 10/10/2008 00:00:01 Server A Class A 1001 jack 101
6 10/10/2008 00:00:01 Server A Class A 1002 jack 102
85 10/10/2008 00:00:01 Server A Class A 1004 aaa 103
84 10/10/2008 00:00:01 Server A Class A 1001 bbb 104
96 10/10/2008 00:00:01 Server A Class A 1001 jack 151
196 10/10/2008 00:00:01 Server A Class A 1001 jack 161
219 10/10/2008 00:00:01 Server A Class A 1001 jack 106
0 10/10/2008 00:00:01 Server A Class A 1001 jack 201
1 10/10/2008 00:00:01 Server A Class A 1001 jack 202
6 10/10/2008 00:00:01 Server A Class A 1001 jack 109
The basic questions are : "Why! & Why not ?"
awk -F" " '! /^[0-1] / && ! /^8[4-6]/ {print $0}' rep1.txt > OtherErrors.log
Regards,
awk -F" " '! /^[0-1] / && ! /^8[4-6]/ {print $0}' rep1.txt > OtherErrors.log
the code above also did not give my result. May be i am not clear with wat i explained before, so i have given the output below, kindly check and advice
thanks
Output Needed for OtherErrors.log
6 10/10/2008 00:00:01 Server A Class A 1002 jack 102
96 10/10/2008 00:00:01 Server A Class A 1001 jack 151
196 10/10/2008 00:00:01 Server A Class A 1001 jack 161
219 10/10/2008 00:00:01 Server A Class A 1001 jack 106
6 10/10/2008 00:00:01 Server A Class A 1001 jack 109
How about this:
awk '
$1 == 0 || $1 ==1 {print > "success.log"; next }
$1 == 84 || $1 ==85 || $1==86 { print > "MediaErr.log"; next }
{ print > "OtherErrors.log" }
' rep1.txt
awk '
$1 ~ /^[0-1]$/ {print $0 >> "rep1.txt"; continue }
$1 ~ /^8[4-6]$/ {print $0 >> "MediaErr.txt"; continue }
$1 ~ /^[0-9].*/ {print $0 >> "OtherErr.log" }
' 63895_awkfiler.d