Which two settings will display the name of the variable and its value?

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?

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.



Leave a Reply 13

Your email address will not be published. Required fields are marked *


Momo

Momo

A,B

Nwildner

Nwildner

It will not work because “grep” is not uppercase on this option.

alf_dba

alf_dba

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

B,C

B,C are correct answers

vasben

vasben

B and C are correct

the tuk-ITE'05 CON-KMITL

the tuk-ITE'05 CON-KMITL

[root@OraLinux6 ~]# SERVICE=ACCTS
[root@OraLinux6 ~]# set | grep SERVICE
SERVICE=ACCTS
[root@OraLinux6 ~]# echo $SERVICE
ACCTS
[root@OraLinux6 ~]#

senthil

senthil

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]#

senthil

senthil

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]#

Jef Adams

Jef Adams

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

ALEX

ALEX

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.

S Idris

S Idris

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?