Linux Shell

  Home  Operating System Linux  Linux Shell


“Linux OS Shell frequently Asked Questions by expert members with experience in Linux Shell. These questions and answers will help you strengthen your technical skills, prepare for the new job test and quickly revise the concepts”



53 Linux Shell Questions And Answers

28⟩ What is the output of this program? #!/bin/bash function san_function1 { echo "This is first function" } san_function2() { echo "This is second function" } san_function1 san_function2 exit 0 a) This is the first function b) This is the second function c) This is the first function This is the second function d) program will generate error because first function definition is not correct

c) This is the first function

This is the second function

 144 views

29⟩ What is the output of this program? #!/bin/sh san_function1() { a=5 echo "This is the first function" san_function2 } san_function2() { echo "This is the second function" san_function3 } san_function3() { echo "This is the third function" } san_function1 exit 0 a) This is the first function This is the second function This is the third function b) This is the first function This is the third function This is the second function c) This is the second function This is the first function This is the third function d) This is the third function This is the first function This is the second function

a) This is the first function

This is the second function

This is the third function

Output:

root@ubuntu:/home/google# ./test.sh

This is the first function

This is the second function

This is the third function

root@ubuntu:/home/google#

 138 views

31⟩ What is the output of this program? #!/bin/bash san_var="google" echo "$san_var" echo '$san_var' echo '"$san_var"' echo "'$san_var'" echo $san_var exit 0 a) google $san_var "$san_var" 'google' $san_var b) google google "google" 'google' google c) program will generate an error message d) program will print nothing

a) google

$san_var

"$san_var"

'google'

$san_var

Explanation:

Using double quotes does not affect the substitution of the variable, while single quotes and backslash do.

Output:

root@ubuntu:/home/google# ./test.sh

google

$san_var

"$san_var"

'google'

$san_var

root@ubuntu:/home/google#

 142 views

32⟩ What is the output of this program? #!/bin/bash var1=10 $var1=20 echo $var1 exit 0 a) program will print 10 b) program will generate a warning message c) program will print 20 d) both (a) and (b)

d) both (a) and (b)

Explanation:

The doller sign ($) is used to access a variable's value, not to define it.

Output:

root@ubuntu:/home/google# ./test.sh

./test.sh: line 3: 10=20: command not found

10

root@ubuntu:/home/google#

 150 views