exam questions

Exam 010-160 All Questions

View all questions & answers for the 010-160 exam

Exam 010-160 topic 1 question 68 discussion

Actual exam question from LPI's 010-160
Question #: 68
Topic #: 1
[All 010-160 Questions]

The file script.sh in the current directory contains the following content:
#!/bin/bash
echo $MYVAR
The following commands are used to execute this script:

MYVAR=value -
./script.sh
The result is an empty line instead of the content of the variable MYVAR. How should MYVAR be set in order to make script.sh display the content of MYVAR?

  • A. !MYVAR=value
  • B. env MYVAR=value
  • C. MYVAR=value
  • D. $MYVAR=value
  • E. export MYVAR=value
Show Suggested Answer Hide Answer
Suggested Answer: E 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
sasquatchshrimp
Highly Voted 2 years, 1 month ago
A good source to look into more on this. https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-environment-variables-in-linux/
upvoted 6 times
Miketunzy
1 year, 1 month ago
Reviewed. Thank you!
upvoted 2 times
...
...
FM221228
Highly Voted 3 months, 2 weeks ago
We need to export the variable for it to be inherited by another program - including a shell script.
upvoted 5 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago