You want to display the value of a shell variable called service after assigning a value as shown:
SERVICE =ACCT S
Which two settings will display the name of the variable and its value?
A.
set | grep service
B.
echo $SERVICE
C.
env | grep SERVICE
D.
env $SERVICE
E.
set $SERVICE
Explanation:
C: env – set the environment for command invocation
If no utility operand is specified, the resulting environment shall be written to the standard output,
with one name= value pair per line.
A,B
It will not work because “grep” is not uppercase on this option.
The correct answer are: B and C.
The “A” is wrong because the variable service is lowercase. Correct would be set | grep SERVICE
B,C are correct answers
B & C
B and C are correct
[root@OraLinux6 ~]# SERVICE=ACCTS
[root@OraLinux6 ~]# set | grep SERVICE
SERVICE=ACCTS
[root@OraLinux6 ~]# echo $SERVICE
ACCTS
[root@OraLinux6 ~]#
Answer: A & C
[root@oracleblr ipv4]# echo $SERVICE
[root@oracleblr ipv4]# env | grep SERVICE
[root@oracleblr ipv4]# SERVICE=ACCTS
[root@oracleblr ipv4]# echo $SERVICE
ACCTS
[root@oracleblr ipv4]# env | grep SERVICE
[root@oracleblr ipv4]# set | grep SERVICE
SERVICE=ACCTS
[root@oracleblr ipv4]#
Sorry
Answer: A & B
[root@oracleblr ipv4]# echo $SERVICE
[root@oracleblr ipv4]# env | grep SERVICE
[root@oracleblr ipv4]# SERVICE=ACCTS
[root@oracleblr ipv4]# echo $SERVICE
ACCTS
[root@oracleblr ipv4]# env | grep SERVICE
[root@oracleblr ipv4]# set | grep SERVICE
SERVICE=ACCTS
[root@oracleblr ipv4]#
B C
In any case answers B is ONLY correct.
For A service should be in uppercase :
[Jef@ToshibaZ30-Jef ~]$ set | grep SERVICE
SERVICE=ACCTS
For C an export SERVICE has to be done after SERVICE=ACCTS cli :
[Jef@ToshibaZ30-Jef ~]$ env | grep SERVICE
[Jef@ToshibaZ30-Jef ~]$ export SERVICE
[Jef@ToshibaZ30-Jef ~]$ env | grep SERVICE
SERVICE=ACCTS
[Jef@ToshibaZ30-Jef ~]$ SERVICE=ACCTS
[Jef@ToshibaZ30-Jef ~]$ echo $SERVICE
ACCTS
[Jef@ToshibaZ30-Jef ~]$ set | grep SERVICE
SERVICE=ACCTS
[Jef@ToshibaZ30-Jef ~]$ env | grep SERVICE
[Jef@ToshibaZ30-Jef ~]$ export SERVICE
[Jef@ToshibaZ30-Jef ~]$ env | grep SERVICE
SERVICE=ACCTS
[Jef@ToshibaZ30-Jef ~]$ set | grep SERVICE
SERVICE=ACCTS
Only C is correct. Just tested it. A is wrong because service is low-case, B is wrong because it only displays the value. D E display nothing.
Hi all,
Thank you for all your effort and valuable comments.
I am going to sit the exam in 3 weeks. Can someone please verify if i can still use these questions to prepare for the exam?