Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam LFCS topic 1 question 121 discussion

Actual exam question from Linux Foundation's LFCS
Question #: 121
Topic #: 1
[All LFCS Questions]

What output will the following command sequence produce?
echo '1 2 3 4 5 6' | while read a b c; do
echo result: $c $b $a;
done

  • A. result: 3 4 5 6 2 1
  • B. result: 1 2 3 4 5 6
  • C. result: 6 5 4
  • D. result: 6 5 4 3 2 1
  • E. result: 3 2 1
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
9866666
1 week, 5 days ago
Selected Answer: A
$ echo '1 2 3 4 5 6' | while read a b c; do echo result: $c $b $a; done result: 3 4 5 6 2 1
upvoted 1 times
...
boorce
3 months, 1 week ago
Selected Answer: A
Confirm in bash: a='1' b='2' c='3 4 5 6' So echo result: $c $b $a => result: 3 4 5 6 2 1
upvoted 2 times
...
EliteAllen
6 months ago
Selected Answer: E
$ echo '1 2 3 4 5 6' | while read a b c; do > echo result: $c $b $a; > done result: 3 4 5 6 2 1
upvoted 1 times
EliteAllen
6 months ago
Excuse me. Correct answer is A.
upvoted 1 times
...
...
ARH2023
7 months, 4 weeks ago
The given command sequence reads input numbers '1 2 3 4 5 6' and then uses a while loop to assign them to variables a, b, and c, respectively. It then echoes these variables in reverse order. Here's the output: makefile result: 3 2 1 So, the output will be "result: 3 2 1" for each iteration of the while loop, as it reverses the order of the input numbers.
upvoted 1 times
...
KMAV
1 year, 3 months ago
Selected Answer: E
The given command sequence reads a string "1 2 3 4 5 6" using the echo command, then pipes it to a while loop that reads each of the space-separated values into the variables a, b, and c in turn. The loop then echoes the values of c, b, and a in that order, preceded by the string "result: ". Since the loop reads the values into a, b, and c in that order, and the loop echoes them in reverse order, the resulting output will be: result: 3 2 1
upvoted 1 times
...
Ivandrago
2 years, 6 months ago
a=1,b=2,c=3456 so echo 345621
upvoted 1 times
...
Borbz
3 years, 4 months ago
the answer is correct, tested in lab. But i can't understand the logic of it... can anyone explain?
upvoted 1 times
Borbz
3 years, 4 months ago
ok, i got the logic. The "read a" records the first value (1), "read b" records the second value (2) and the last read "read c" records all remaining values (3 4 5 6). therefore the output of $c $b $a is 3 4 5 6 2 1.
upvoted 4 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
ex Want to SAVE BIG on Certification Exam Prep?
close
ex Unlock All Exams with ExamTopics Pro 75% Off
  • arrow Choose From 1000+ Exams
  • arrow Access to 10 Exams per Month
  • arrow PDF Format Available
  • arrow Inline Discussions
  • arrow No Captcha/Robot Checks
Limited Time Offer
Ends in