what are the USERID,PASSWD in /etc/passwd



I want to modify it so that i can get userid and passwd form the
given
unername
help me

#!/bin/bash
# realname.sh
#
# From username, gets "real name" from /etc/passwd.


ARGCOUNT=1 # Expect one arg.
E_WRONGARGS=65


file=/etc/passwd
pattern=$1


if [ $# -ne "$ARGCOUNT" ]
then
echo "Usage: `basename $0` USERNAME"
exit $E_WRONGARGS
fi


file_excerpt () # Scan file for pattern, then print relevant portion
of line.
{
while read line # "while" does not necessarily need "[ condition ]"
do
echo "$line" | grep $1 | awk -F":" '{ print $5 }' # Have awk use
":" delimiter.
done



} <$file # Redirect into function's stdin.


file_excerpt $pattern

# Yes, this entire script could be reduced to
# grep PATTERN /etc/passwd | awk -F":" '{ print $5 }'
# or
# awk -F: '/PATTERN/ {print $5}'
# or
# awk -F: '($1 == "username") { print $5 }' # real name from
username
# However, it might not be as instructive.


exit 0

.



Relevant Pages

  • Re: perl file parsing
    ... AGGACATGCGGCCCGGCGACCTCATCATCTACTTCGACGACGCCAGCCACGTCGGGATG ... the number of times the pattern has occured. ... chomp; #remove newline characters ...
    (perl.beginners)
  • Re: simple question
    ... while read first rest; do ... # This contains the username who invoked the script ... echo "The given file $FILE does not exists" ...
    (comp.unix.programmer)
  • Re: simple problem
    ... I have written the script like this: ... echo "The given file $FILE does not exists" ... while read USERNAME REST ...
    (comp.unix.questions)
  • Re: [sudo-users] How to disable ( deny ) user to change the password of root
    ... # Validate that a username was given as an argument ... only some of special user who can running some of cmd via sudo... ...
    (Fedora)
  • Re: Calculate Last Digits
    ... This might work faster by adding the following line at this point: ... Exit For, as discussed at enormous length in older threads, but this is ... I did get a big boost by switching from strings to longs for the pattern ...
    (microsoft.public.vb.general.discussion)