Presentation is loading. Please wait.

Presentation is loading. Please wait.

How shell works Shell reads in input, parse & process it, the resulting string is taken to be argv[] and executed echo a  shell sees “ echo a ” echo gets.

Similar presentations


Presentation on theme: "How shell works Shell reads in input, parse & process it, the resulting string is taken to be argv[] and executed echo a  shell sees “ echo a ” echo gets."— Presentation transcript:

1 How shell works Shell reads in input, parse & process it, the resulting string is taken to be argv[] and executed echo a  shell sees “ echo a ” echo gets argv[]= “ echo ” “ a ”, prints out a a=b; echo $a  shell sees “ echo $a ”, change it to “ echo b ” echo gets argv[]= “ echo ” “ b ”, prints out b

2 How shell works a=b; b=c; echo \$$a  shell sees “ echo \$$a ” shell interprets \$ as the char ‘ $ ’ shell interprets $a as “ b ” the resulting string is “ echo $b ” echo gets argv[]= “ echo ” “ $b ” echo prints out $b on the screen What if I want the value of b printed on the screen?

3 How eval works a=b; b=c; eval echo \$$a  shell sees “ eval echo \$$a ” shell takes away eval shell interprets \$ as the char ‘ $ ’ shell interprets $a as “ b ” the resulting string is “ echo $b ” because of eval, shell parses this string once again shell interprets $b as “ c ” echo gets argv[]= “ echo ” “ c ” echo prints out c on the screen

4 Command Path The shell variable $path specifies where to search for commands If not found, shells prints “ Command not found ” To be very specific, use full pathname, such as /sbin/dumpon -v ${dumpdev}

5 Notable Commands vinum swapon fsck mount (& fstab) find

6 Difference between. And Sh Both “. script1 ” and “ sh script1 ” executes script1 Both have the same permanent side effect, such as the removal of a file. does the work in the same shell sh does the work in a separate shell If what you want is the side effect within the shell, such as the value of a shell variable, use. instead of sh.


Download ppt "How shell works Shell reads in input, parse & process it, the resulting string is taken to be argv[] and executed echo a  shell sees “ echo a ” echo gets."

Similar presentations


Ads by Google