Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Linux OS Interviews:Awk ProgrammingBash Arithmetic ExpressionsDevice DriversGCC CompilerLinux AdministratorLinux CommandsLinux DebuggingLinux EnvironmentLinux GeneralLinux IPCLinux MakefileLinux OSLinux OS EditorsLinux OS ManagementLinux OS ShellLinux Proc FilesystemLinux Search PatternLinux Shared & Static LibrariesLinux Socket ProgrammingLinux Startup and ShutdownLinux SysfsLinux SystemsLinux ThreadsLinux UbuntuSignal HandlingSystem Calls
Copyright © 2018. All Rights Reserved
Linux OS Shell Interview Question:
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
Submitted by: Murtazaa) 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#
Submitted by: Murtaza
$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
$san_var
"$san_var"
'google'
$san_var
root@ubuntu:/home/google#
Submitted by: Murtaza
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.