close

1.
題目:

$MYVAR1="Happy"

$MYVAR2="Birthday"

$export MYVAR1

$bash

$echo $MYVAR1 $MYVAR2

$exit

$echo $MYVAR1 $MYVAR2

a. Was the behavior of the two echo commands identical?

b. If so,why?If not,why not?

c. What happened immediately after the bash command?

d.Which variable is an environment variable?


實際執行過程:

[Niki@13:47:29 ~]$ MYVAR1="Happy"
[Niki@13:47:44 ~]$ MYVAR2="Birthday"
[Niki@13:48:02 ~]$ export MYVAR1
[Niki@13:48:19 ~]$ bash
[Niki@localhost ~]$ echo $MYVAR1 $MYVAR2
Happy
[Niki@localhost ~]$ exit
exit
[Niki@13:48:53 ~]$ echo $MYVAR1 $MYVAR2

Happy Birthday


答案:

[Niki@13:49:23 ~]$ #a. not identicial
[Niki@13:50:33 ~]$ #b. export 
[Niki@13:51:21 ~]$ #c. enter another bash
[Niki@13:53:25 ~]$ #d. $MYVAR1 $MYVAR2

2.題目:

enter Ctrl-P until you see the last echo command.Enter Ctrl-P again.

a. What do you see?

b. Why wasn't  it the exit command?

c. Enter Ctrl-P again so that the export command is displayed.

   Add a space and MYVAR2 so that the line now looks like this:

  $export MYVAR1 MYVAR2

  What happens when you enter this command?

答案:

[Niki@14:29:42 ~]$ #a. bash

[Niki@14:29:56 ~]$ #b. because exit command is new instruction of bash

[Niki@14:30:45 ~]$ MYVAR1="Happy"

[Niki@14:31:01 ~]$ MYVAR2="Birthday"

[Niki@14:31:16 ~]$ export MYVAR1

[Niki@14:31:32 ~]$ bash

[Niki@localhost ~]$ echo $MYVAR1 $MYVAR2
Happy
[Niki@localhost ~]$ exit
exit
[Niki@14:32:05 ~]$ echo $MYVAR1 $MYVAR2

Happy Birthday

[Niki@14:32:26 ~]$ export MYVAR1 MYVAR2

[Niki@14:32:54 ~]$ bash

[Niki@localhost ~]$ echo $MYVAR1 $MYVAR2
Happy Birthday
[Niki@localhost ~]$ exit

exit

[Niki@14:33:22 ~]$ echo $MYVAR1 $MYVAR2

Happy Birthday

[Niki@14:33:25 ~]$ #c. we can see Happy Birthday


3.   題目:


The file command is used to examine a file's contents and displays

the file type.

Explain the result of using file as follows:

   $cd / ; file $(ls | head -10)


實際執行過程:

[Niki@14:39:34 ~]$ cd / ; file $(ls | head -10)
bin:        directory
boot:       directory
dev:        directory
etc:        directory
home:       directory
lib:        directory
lost+found: directory
media:      directory
misc:       directory
mnt:        directory

答案:路徑指向根目錄,且顯示10個檔案的file type






arrow
arrow
    文章標籤
    Shell
    全站熱搜

    布拉怡 發表在 痞客邦 留言(0) 人氣()