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
6 months agoTenesha
6 months agoCrissy
6 months agoFloyd
7 months agoLeanora
7 months agoChantay
7 months agoGlendora
7 months agoRosann
7 months agoDaisy
8 months agoOneida
8 months agoCharlena
8 months agoGlenna
8 months agoCasandra
8 months agoTimmy
8 months agoMozelle
12 months agoAlease
12 months agoCory
12 months agoErick
11 months agoJanae
11 months agoGilbert
11 months agoBettyann
12 months agoShaniqua
12 months agoShanice
12 months agoKrissy
11 months agoBeata
11 months agoCoral
1 year agoLaurel
1 year agoGlory
1 year agoLaurena
11 months agoNelida
11 months agoLatricia
12 months agoRoslyn
12 months ago