Click to See Complete Forum and Search --> : Help with scripts ..


princem3
10-14-2003, 09:01 PM
I need some help with the following scripts. ..


So please help me answer the questions for each of the scripts? I'm reading these scripts both for a class and some side project here at home.


#!/bin/sh
usr=$1

What will be the contents of MATCH after the statement is executed?


if MATCH=`grep "^$usr" /etc/passwd`
then

What will the contents of RN be after the statement is executed?

RN=`echo $MATCH | cut -d: -f5`
fi

Why did I assign the output of the grep command to MATCH?

Satanic Atheist
10-14-2003, 09:03 PM
Shouldn't this be in the Programming forum?

James

serz
10-14-2003, 09:27 PM
Originally posted by Satanic Atheist
Shouldn't this be in the Programming forum?
Yes. Moving there...

bsh152s
10-16-2003, 02:24 PM
I hope this isn't a homework assignment.

Anyway, this script accepts a username as a parameter and prints the 5th field in the password file for that user. The MATCH string will contain the full line from the password file. The cut command will just take out the 5th field from this line assuming the fields are delimited by ":". I can't remember the password file layout and I'm on a windows machine right now. Otherwise, I'd tell you what the 5th field is. It may be the real name of the user. Just a guess though.