U.S. Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

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
Question #: 100
Topic #: 5
[All LFCS Questions]

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?

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Felix
6 months ago
I agree with B, it's how positional parameters work.
upvoted 0 times
...
Tenesha
6 months ago
Wait, are you sure? I thought it would be A.
upvoted 0 times
...
Crissy
6 months ago
Definitely B! It prints in reverse order.
upvoted 0 times
...
Floyd
7 months ago
I’m surprised it doesn’t just print the script name!
upvoted 0 times
...
Leanora
7 months ago
The output will be test2 test1.
upvoted 0 times
...
Chantay
7 months ago
I might be confused, but I thought the script would just print the script name instead of the arguments.
upvoted 0 times
...
Glendora
7 months ago
I practiced a similar question, and I believe it outputs the second argument first, so it should be test2 test1.
upvoted 0 times
...
Rosann
7 months ago
I'm not entirely sure, but I remember something about the order of arguments being important.
upvoted 0 times
...
Daisy
8 months ago
I think the script uses positional parameters, so $1 is the first argument and $2 is the second.
upvoted 0 times
...
Oneida
8 months 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.
upvoted 0 times
...
Charlena
8 months 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.
upvoted 0 times
...
Glenna
8 months 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.
upvoted 0 times
...
Casandra
8 months 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.
upvoted 0 times
...
Timmy
8 months 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.
upvoted 0 times
...
Mozelle
12 months 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!
upvoted 0 times
...
Alease
12 months ago
I'm not sure, but I think the answer is B) test2 test1 as well.
upvoted 0 times
...
Cory
12 months 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!
upvoted 0 times
Erick
11 months ago
Bash scripts can be tricky, but this one is pretty straightforward.
upvoted 0 times
...
Janae
11 months ago
Yeah, that script is just swapping the arguments around.
upvoted 0 times
...
Gilbert
11 months ago
I think you're right, B) test2 test1 is the correct output.
upvoted 0 times
...
...
Bettyann
12 months ago
I agree with Laurel, because the script will echo the second argument first.
upvoted 0 times
...
Shaniqua
12 months ago
Let's see, the script is echoing the arguments in reverse order. That means B) test2 test1 is the correct answer. *fingers crossed*
upvoted 0 times
...
Shanice
12 months 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.
upvoted 0 times
Krissy
11 months ago
User 2: Yeah, that makes sense. The script is just swapping the arguments.
upvoted 0 times
...
Beata
11 months ago
User 1: I think it will output test2 test1.
upvoted 0 times
...
...
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!
upvoted 0 times
...
Laurel
1 year ago
I think the output will be B) test2 test1.
upvoted 0 times
...
Glory
1 year ago
Hmm, this looks like a classic shell script argument handling question. I'll go with B) test2 test1.
upvoted 0 times
Laurena
11 months ago
User4: I agree with User2, it should be B) test2 test1.
upvoted 0 times
...
Nelida
11 months ago
User3: I'm not sure, but I think it might be C) script.sh test2.
upvoted 0 times
...
Latricia
12 months ago
User2: No, I believe it will be B) test2 test1.
upvoted 0 times
...
Roslyn
12 months ago
User1: I think the output will be A) test1 test2.
upvoted 0 times
...
...

Save Cancel