Computing.Net > Forums > Unix > wildcard in loop awk

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

wildcard in loop awk

Reply to Message Icon

Name: abhargav
Date: May 16, 2005 at 20:22:02 Pacific
OS: unix
CPU/Ram: 256 SDRAM
Comment:

hi all
i m just stuffed in a problem if somebody can help me out
i hav /etc/shadow file with enteries like

bin:*:9797:0:::::
daemon:*:9797:0:::::
adm:*:9797:0:::::
lp:*:9797:0:::::
sync:*:9797:0:::::
shutdown:*:9797:0:::::
halt:*:9797:0:::::
mail:*:9797:0:::::
news:*:9797:0:::::
uucp:*:9797:0:::::
abhargav:$1$c6F/ngOF$drzN.QbsW2VK69SgHXsRL/:12868:0:99999:7:::
aby:$1$KkQ0GmPM$0Huso4Y.16OI9clt3keeU0:12890:0:99999:7:::

now i want to check whether the second entry with "*" wildcard is there or not
so my code is

#!/bin/sh

for WHO in `awk -F":" '{print $2}' /etc/shadow` ; do
if [ "${WHO}" = '*' ] ; then
echo "they are not the real users "
else
echo "they are users ${WHO} "

fi
done

but some how it doesnt take "*" it starts counting the files in the directories
i m getting mad @ it.plz help

hi
my question is abt scripting.
i want to find the diffrence in two dates.
dates are in /var/log/messages

Mar 27 05:48:02 abhargav sshd[1151]:
Apr 2 15:31:17 abhargav sshd[1151]:

no



Sponsored Link
Ads by Google

Response Number 1
Name: Luke Chi
Date: May 16, 2005 at 21:44:08 Pacific
Reply:

cat /etc/shadow | while read LINE
do
WHO="\\"`echo $LINE | cut -d":" -f2`
if [ $WHO = '\*' ] ; then
echo "they are not the real users "
else
echo "they are users `echo $WHO | cut -c2-"
fi
done

Luke Chi


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: wildcard in loop awk

AWK in a while loop www.computing.net/answers/unix/awk-in-a-while-loop/6669.html

echo wildcard in variable www.computing.net/answers/unix/echo-wildcard-in-variable/6911.html

write log in loop - ksh script www.computing.net/answers/unix/write-log-in-loop-ksh-script/4721.html