This discussion is archived
2 Replies Latest reply: Oct 5, 2012 6:04 AM by vaaru RSS

To remove the null value using awk on RHEL5

vaaru Newbie
Currently Being Moderated
HI,

this is some lines from /var/log/secure
Oct 4 09:55:31 dcvlodbdev su: pam_unix(su-l:auth): authentication failure; logname=oratest uid=501 euid=0 tty=pts/1 ruser=oratest rhost= user=one
Oct 4 10:56:06 dcvlodbdev sshd[9131]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=172.16.201.23 user=oratest


i am using this awk cmd for our reqiurment,



/bin/grep "$CUR_DATE" /var/log/secure | grep -i failure | awk '{ print $1, $2"  ", $3" ",$14"  ", $15 }' >> /tmp/failed-logins.txt


I received the output as,
Oct 4 10:56:06 logname= rhost=172.16.201.23 user=oratest
Oct 4 10:56:37 logname=oratest rhost= user=root

But i only need the ouput like this,

Oct 4 10:56:06 logname= rhost=172.16.201.23 user=oratest

i dont need the "rhost= "
how to avoid the rhost="null" in awk

Thanks.
Vaaru

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points