Skip to main content
added 34 characters in body
Source Link
Rahul
  • 14k
  • 4
  • 46
  • 56

I am currently writing something to parse some apache logs, yet the "system"system command seems to be putting itself above print. Haven't done a whole lot with awkawk, so it could be something very simple.

IFS=$'\n' 
for ja in `cat test.apache.access_log | awk '{print $1}' | sort -n | uniq -c | sort -rn | head -3`
do 
echo $ja|awk '{print "Count\tIP\t\tNSLookup"}{print $1"\t",$2,"\t\t",system("nslookup " $2"|grep name")}'
done

IFS=$'\n' for ja inWhat I get cat test.apache.access_log | awk '{print $1}' | sort -n | uniq -c | sort -rn | head -3 do echo $ja|awk '{print "Count\tIP\t\tNSLookup"}{print $1"\t",$2,"\t\t",system("nslookup " $2"|grep name")}' done:

Count IP NSLookup RR.ZZ.YY.XX.in-addr.arpa name = ja.server.net. 241 XX.YY.ZZ.RR 0

Count   IP              NSLookup
RR.ZZ.YY.XX.in-addr.arpa      name = ja.server.net.
241      XX.YY.ZZ.RR           0 

What I would like to see is: Count IP NSLookup 241 XX.YY.ZZ.RR RR.ZZ.YY.XX.in-addr.arpa name = ja.server.net.

Thanks for any help

B

Count   IP              NSLookup
241      XX.YY.ZZ.RR          RR.ZZ.YY.XX.in-addr.arpa      name = ja.server.net. 

I am currently writing something to parse some apache logs, yet the "system" command seems to be putting itself above print. Haven't done a whole lot with awk, so it could be something very simple.

IFS=$'\n' for ja in cat test.apache.access_log | awk '{print $1}' | sort -n | uniq -c | sort -rn | head -3 do echo $ja|awk '{print "Count\tIP\t\tNSLookup"}{print $1"\t",$2,"\t\t",system("nslookup " $2"|grep name")}' done

Count IP NSLookup RR.ZZ.YY.XX.in-addr.arpa name = ja.server.net. 241 XX.YY.ZZ.RR 0

What I would like to see is: Count IP NSLookup 241 XX.YY.ZZ.RR RR.ZZ.YY.XX.in-addr.arpa name = ja.server.net.

Thanks for any help

B

I am currently writing something to parse some apache logs, yet the system command seems to be putting itself above print. Haven't done a whole lot with awk, so it could be something very simple.

IFS=$'\n' 
for ja in `cat test.apache.access_log | awk '{print $1}' | sort -n | uniq -c | sort -rn | head -3`
do 
echo $ja|awk '{print "Count\tIP\t\tNSLookup"}{print $1"\t",$2,"\t\t",system("nslookup " $2"|grep name")}'
done

What I get :

Count   IP              NSLookup
RR.ZZ.YY.XX.in-addr.arpa      name = ja.server.net.
241      XX.YY.ZZ.RR           0 

What I would like to see is:

Count   IP              NSLookup
241      XX.YY.ZZ.RR          RR.ZZ.YY.XX.in-addr.arpa      name = ja.server.net. 
Source Link

AWK output help

I am currently writing something to parse some apache logs, yet the "system" command seems to be putting itself above print. Haven't done a whole lot with awk, so it could be something very simple.

IFS=$'\n' for ja in cat test.apache.access_log | awk '{print $1}' | sort -n | uniq -c | sort -rn | head -3 do echo $ja|awk '{print "Count\tIP\t\tNSLookup"}{print $1"\t",$2,"\t\t",system("nslookup " $2"|grep name")}' done

Count IP NSLookup RR.ZZ.YY.XX.in-addr.arpa name = ja.server.net. 241 XX.YY.ZZ.RR 0

What I would like to see is: Count IP NSLookup 241 XX.YY.ZZ.RR RR.ZZ.YY.XX.in-addr.arpa name = ja.server.net.

Thanks for any help

B