In: Computer Science
Unix / Linux
31.
Given the first two commands, what is the expected output for the third command? (single quotes)
$ echo *
a b c
$ x=*
$ echo '$x'
32.
Given the first two commands, what is the expected output for the third command? (Single quotes inside of double quotes)
$ echo *
a b c
$ x=*
$ echo "'$x'"
33.
Given the first two commands, what is the expected output for the third command? (double quotes inside of single quotes)
$ echo *
a b c
$ x=*
$ echo '"$x"'
34.
Given the first two commands, what is the expected output for the third command? (double quotes)
$ echo *
a b c
$ x=*
$ echo "$x"
35.
Given the first two commands, what is the expected output for the third command? (no quotes)
$ echo *
a b c
$ x=*
$ echo $x
31.
$ x=*
$ echo '$x'
OUTPUT: $x
whatever you write with in the single quotes, it is consider as a text to display. so the output is $x
32.
$ x=*
$ echo "'$x'"
OUTPUT: '*'
in double quotes, text and symbols are normally displayed but commands starts with $ are executed. here $ is a command used to display the variable value. here the variable is x. $x means * so, the value * is printed on the output screen. single quotes are normally displayed because they are not commands to execute.
33.
$ x=*
$ echo '"$x"'
OUTPUT: "$x"
In sigle quotes, every character and symbol is treated as text, they are not considered as commands. so everything written in single quotes is displayed on the output screen.
34.
$ x=*
$ echo "$x"
OUTPUT: *
Double quotes can execute the commands which are written inside it. here $x is a command. so it is executed and displayed the value of x to output console.
35.
$ x=*
$ echo $x
OUTPUT: *
you can display the variable value in unix without any quotes or by using double quotes. $x is a command to display the value of the x to output console. so * is printed on the output screen.