shell script query

Hi Admins,

I was trying to list the failed logins as part of my daily checklist.
Here is my script

for i in `who -s /etc/security/failedlogins|tail -100|grep "$dt"|awk '{print $1"  "$6}'`
do
a=`echo $i|wc -l`
if [ $a -gt 0 ]
then
echo $i
else
echo "There are no failed logins"
fi
done

but m getting output in multiple lines.If there are two entries output will be scattered in multiple lines.Please tell me how to print the output in 2 lines(for 2 entries for example). I have used \n with echo $i.. but no use..

Regards
new aix

try

echo "$i"
`who -s /etc/security/failedlogins | tail -100| awk -v dt=$dt ' /dt/ {print $1" "$6}'`

Hi

I dont undesrstand why you use "tail -100" ?
You can try this :

who -s /etc/security/failedlogins | awk '    BEGIN {i=0} 
                                            $0 ~ var {print $1" "$6; i++}
                                            END {if (i == 0) print "There are no failed logins"}' var=$dt

Regards
jmc0031

thanks for the reply... it has solved my problem..