In Bash Shell Assume the command and output below echo PS1 g

In Bash Shell

Assume the command and output below:

echo $PS1

general >

Give the printout of the following sequential commands. Be sure to write “nothing” if the only thing appearing on the screen is the next prompt. Be sure to write “blank line” if a blank line is printed.

general > i=class; j=is; k=over

Nothing

general > echo $i $j $k

Class is over

general > sh

! general > echo $i $j $k

! general > i=Be; j=nice

! general > exit

general > echo $i $j $k

general > sh

! general > echo $i $j $k

! general > export i j

! general > i=enjoy; j=this

! general > echo $i $j $k

! general > exit

general > echo $i $j $k

general > export i j k

general > sh

! general > echo $i $j $k

! general > export i j

! general > i=enjoy; j=this

! general > sh

!! general > echo $i $j $k

!! general > exit

! general > exit

general > echo $i $j $k

Solution

Output of given sequential commands is mentioned in table below along with explanation.

S.No. Command Output Explanation
1 i=class; j=is; k=over Nothing As i, j, k are successfully set without any error (in say, shell1)
2 echo $i $j $k class is over As per values set for i, j, k in current bash shell (shell1)
3 sh Nothing As new shell instance is created (say, shell2)
4 echo $i $j $k Blank line As i, j, k are not initialized in newly created shell instance (shell2)
5 i=Be; j=nice Nothing As i, j are successfully set without any error (shell2)
6 exit Nothing As newly created shell instance (i.e. shell2) is destroyed and previous bash shell (shell1) is returned
7 echo $i $j $k class is over As per values set for i, j, k earlier in the bash shell returned (shell1)
8 sh Nothing As new shell instance is created (shell3)
9 echo $i $j $k Blank line As i, j, k are not initialized in newly created shell instance (shell3)
10 export i j Nothing As i, j variables export attribute is set
11 i=enjoy; j=this Nothing As i, j are successfully set without any error (shell3)
12 sh Nothing As another new shell instance is created (say, shell4)
13 echo $i $j $k enjoy this As values of only exported variables i, j are printed
14 exit Nothing As newly created shell instance (i.e. shell4) is destroyed and previous shell (shell3) is returned
15 exit Nothing As shell3 is destroyed and previous bash shell (shell1) is returned
16 echo $i $j $k class is over As per values set for i, j, k earlier in the bash shell returned (shell1). Note that variables exported in child shell are not propogated to parent shell.
In Bash Shell Assume the command and output below: echo $PS1 general > Give the printout of the following sequential commands. Be sure to write “nothing” if
In Bash Shell Assume the command and output below: echo $PS1 general > Give the printout of the following sequential commands. Be sure to write “nothing” if

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site