Question
The following script parses the password file and prints it out by the user's realname home directory login name #!/bin/sh OLDIFS=$IFS IFS=: cat /etc/passwd |
The following script parses the password file and prints it out by the user's "realname" "home directory" "login name"
#!/bin/sh
OLDIFS=$IFS IFS=:
cat /etc/passwd | while read f1 f2 f3 f4 f5 f6 f7 do
if [ "$f5" ] then
IFS=,
set -- $f5
echo "$f1 $1 $f6" IFS=:
fi done
IFS=$OLDIFS
True False
QUESTION
The following command a lways correctly loops through each of the positional parameters as passed on the command line.
#!/bin/sh
for I in "$*" do
echo $I done
True False
QUESTION 20
The following command sends both standard output and standard error to the same file for the command, cmd1.
cmd1 2>&1 > outfile
True False
QUESTION 21
A sub-shell is created when you do file redirection to a loop and you are running in the bash or korn shell. (The student should test this to verify the answer)
True False
QUESTION 22
Putting a #!/bin/csh as the first line in a shell script will execute the script in the borne shell.
True False
QUESTION 23
After the statement
: ${VISUAL:=vi}
The value of the shell variable VISUAL will ALWAYS be vi.
True False
QUESTION 24
Given the script - test-me
#!/bin/bash PATH=$PATH:
echo $PATH
# end of the script
True/False - the following 2 commands are exactly the same which means there is no change to the user's environment after they execute.
. ./test-me
./test-me
True False
QUESTION 25
Given the following script:
#!/bin/sh
if grep "mrichards" /etc/password then
echo "I FOUND A MATCH"
fi
And the password file of the following:
root:x:0:1:CE.UML.EDU Super-User:/:/bin/sh daemon:x:1:1::/:
bin:x:2:2::/usr/bin: sys:x:3:3::/: adm:x:4:4:Admin:/var/adm:
postfix:x:72:6:Postfix email user:/etc/postfix: lp:x:71:8:Line Printer Admin:/usr/spool/lp: uucp:x:5:5:uucp Admin:/usr/lib/uucp:/usr/bin/true
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico smmsp:x:25:25:SendMail Message Submission Program:/: listen:x:37:4:Network Admin:/usr/net/nls: nobody:x:60001:60001:Nobody:/:
noaccess:x:60002:60002:No Access User:/: beoper:x:30:30:Backup Exec Operator:/users/beoper:/usr/bin/ksh
webservd:x:80:80:Web Server Daemon:/space/apache2/home:/bin/pfsh www:x:100:80:Web Server Daemon:/space/Apache2/home:/bin/pfsh clamav:x:221:221:CLAM VIRIS CHECKER:/opt/clamav:/usr/bin/ksh sshd:x:299:1:Secure Shell:/usr/local/sshd:/usr/bin/true mysql:x:300:300:MySQL Server:/usr/local/mysql:/usr/bin/true
judyf:x:202:14:Judith Feeney,Southwick 305,(978) 934-2926,:/users/judyf:/usr/bin/ksh mrichard:x:1216:200:Michael Richards:/users/faculty/mrichard:/usr/bin/ksh noquota:x:10004:205:No Quota User Do Not delete:/users/students/noquota:/usr/bin/ksh
Then the script is run, the o nly output of the script would be
I FOUND A MATCH
True False
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started