Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Linux Foundation LFCS Exam - Topic 5 Question 100 Discussion

Posted by Lillian on Jun 11, 2025 at 01:11 PM

The script, script.sh, consists of the following lines:

#!/bin/bash

echo $2 $1

Which output will appear if the command, ./script.sh test1 test2, is entered?

Suggested Answer: B

Get Premium LFCS Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
32 comments · newest first
FE
Felix 10 months ago
I agree with B, it's how positional parameters work.
TE
Tenesha 11 months ago
Wait, are you sure? I thought it would be A.
CR
Crissy 11 months ago
Definitely B! It prints in reverse order.
FL
Floyd 11 months ago
I’m surprised it doesn’t just print the script name!
LE
Leanora 11 months ago
The output will be test2 test1.
CH
Chantay 11 months ago
I might be confused, but I thought the script would just print the script name instead of the arguments.
GL
Glendora 12 months ago
I practiced a similar question, and I believe it outputs the second argument first, so it should be test2 test1.
RO
Rosann 12 months ago
I'm not entirely sure, but I remember something about the order of arguments being important.
DA
Daisy 1 year ago
I think the script uses positional parameters, so $1 is the first argument and $2 is the second.
ON
Oneida 1 year ago
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.
CH
Charlena 1 year ago
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.
GL
Glenna 1 year ago
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.
CA
Casandra 1 year ago
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.
TI
Timmy 1 year ago
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.
MO
Mozelle 1 year ago
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!
AL
Alease 1 year ago
I'm not sure, but I think the answer is B) test2 test1 as well.
CO
Cory 1 year ago
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!
ER
Erick 1 year ago
↳ replying to Cory
Bash scripts can be tricky, but this one is pretty straightforward.
JA
Janae 1 year ago
↳ replying to Cory
Yeah, that script is just swapping the arguments around.
GI
Gilbert 1 year ago
↳ replying to Cory
I think you're right, B) test2 test1 is the correct output.
BE
Bettyann 1 year ago
I agree with Laurel, because the script will echo the second argument first.
SH
Shaniqua 1 year ago
Let's see, the script is echoing the arguments in reverse order. That means B) test2 test1 is the correct answer. *fingers crossed*
SH
Shanice 1 year ago
I'm feeling confident about this one. The script is clearly just swapping the order of the arguments, so B is the way to go.
KR
Krissy 1 year ago
↳ replying to Shanice
User 2: Yeah, that makes sense. The script is just swapping the arguments.
BE
Beata 1 year ago
↳ replying to Shanice
User 1: I think it will output test2 test1.
CO
Coral 1 year ago
Woah, hold up! If the script is echoing the arguments in reverse order, then the answer has to be B. Easy peasy!
LA
Laurel 1 year ago
I think the output will be B) test2 test1.
GL
Glory 1 year ago
Hmm, this looks like a classic shell script argument handling question. I'll go with B) test2 test1.
LA
Laurena 1 year ago
↳ replying to Glory
User4: I agree with User2, it should be B) test2 test1.
NE
Nelida 1 year ago
↳ replying to Glory
User3: I'm not sure, but I think it might be C) script.sh test2.
LA
Latricia 1 year ago
↳ replying to Glory
User2: No, I believe it will be B) test2 test1.
RO
Roslyn 1 year ago
↳ replying to Glory
User1: I think the output will be A) test1 test2.
0/2000 characters

Save Cancel