Some Problem in Korne Shell Scripting ... - Unix

This is a discussion on Some Problem in Korne Shell Scripting ... - Unix ; I am trying to get the value of the user id (uid), which is the Korne shell parameter.Then, read the /etc/passwd and keep the lines where the uid is superior to the parameter and write this line in a new ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Some Problem in Korne Shell Scripting ...

  1. Some Problem in Korne Shell Scripting ...

    I am trying to get the value of the user id (uid), which is the Korne
    shell parameter.Then, read the /etc/passwd and keep the lines where
    the uid is superior to the parameter and write this line in a new
    file. But I am not getting what I wanted. Perhaps there is a problem
    with the Syntax below :-

    #!/usr/bin/ksh
    uid=${uid:-/etc/passwd}
    /etc/passwd/read
    $ cut -d: -f1 < uid gt $$


    Can anyone help me, please.

    Thanks,
    Marconi.

  2. Some Problem in Korne Shell Scripting ...

    awk -F: "{ if (\$3 > ${uid}) print \$0 ; }" /etc/passwd

  3. Re: Some Problem in Korne Shell Scripting ...

    On Dec 6, 6:03 am, kirankumar.te...@gmail.com wrote:
    > I am trying to get the value of the user id (uid), which is the Korne
    > shell parameter.Then, read the /etc/passwd and keep the lines where
    > the uid is superior to the parameter and write this line in a new
    > file. But I am not getting what I wanted. Perhaps there is a problem
    > with the Syntax below :-
    >
    > #!/usr/bin/ksh
    > uid=${uid:-/etc/passwd}
    > /etc/passwd/read
    > $ cut -d: -f1 < uid gt $$

    >
    > Can anyone help me, please.
    >
    > Thanks,
    > Marconi.


    One of the following work for you?

    IFS=":"
    while read the_uname x the_uid the_rest; do
    if [ "$the_uid" -gt "1000" ]; then
    echo "$the_uname:$x:$the_uid:$the_rest"
    fi
    done < /etc/passwd

    # ...or
    prompt$ awk -v uidval=1000 'BEGIN { FS=":" } { if($3 > uidval)
    print }' < /etc/passwd


+ Reply to Thread