Find the answer to your Linux question:
Results 1 to 3 of 3
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::::: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Posts
    6

    wildcard in loop awk


    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:999 99: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

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Try "`awk -F: '{print $2}' /etc/shadow`"

  3. #3
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Use sed to find the non-users :
    Code:
    sed -n 's/\([^:]*\):\*:.*/\1 is not a real user/p' /etc/shadow

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •