Linux Foundation LFCS Exam - Topic 5 Question 100 Discussion
The script, script.sh, consists of the following lines:#!/bin/bashecho $2 $1Which output will appear if the command, ./script.sh test1 test2, is entered?
B) test2 test1
A) test1 test2
C) script.sh test2
D) script.sh test1
E) test1 script.sh
Linux Foundation LFCS Exam - Topic 5 Question 100 Discussion
Actual exam question for
Linux Foundation's
LFCS exam
I think the key here is understanding how the shell script is processing the arguments. Since the script is using $2 and $1, the output should be "test2 test1". I'm feeling pretty good about this one.
Hmm, let me think this through. The script is using $2 and $1, so the order of the arguments passed to the script must be important. I'll need to carefully consider the order of the arguments to determine the correct output.
Okay, I've got this. The script is echoing the second argument ($2) followed by the first argument ($1), so the output should be "test2 test1". I'm confident that's the correct answer.
I'm a bit confused here. The script is using $2 and $1, but I'm not sure which one corresponds to the first and second arguments passed to the script. I'll need to double-check the order of the arguments.
Hmm, this looks straightforward. I think the output will be "test2 test1" since the script is echoing the second argument followed by the first argument.
Alright, let's think this through. The script is echoing the arguments in reverse order, so B) test2 test1 is the correct output. Easy peasy, lemon squeezy!
This is a no-brainer! The script is just reversing the order of the arguments, so B has to be the right answer. *chuckles* Bash scripts, gotta love 'em!
Felix
7 months agoTenesha
8 months agoCrissy
8 months agoFloyd
8 months agoLeanora
8 months agoChantay
8 months agoGlendora
9 months agoRosann
9 months agoDaisy
9 months agoOneida
9 months agoCharlena
9 months agoGlenna
10 months agoCasandra
10 months agoTimmy
10 months agoMozelle
1 year agoAlease
1 year agoCory
1 year agoErick
1 year agoJanae
1 year agoGilbert
1 year agoBettyann
1 year agoShaniqua
1 year agoShanice
1 year agoKrissy
1 year agoBeata
1 year agoCoral
1 year agoLaurel
1 year agoGlory
1 year agoLaurena
1 year agoNelida
1 year agoLatricia
1 year agoRoslyn
1 year ago