This experiment contains two tasks, content of SHELL program involving the design methods and techniques, specific requirements are as follows:
(1) create the following menu program:
DATE: * */* */2021
USER: * * * *
A: file statistics
B: file character conversion C: command type query Q: exit system
HOST: * * * * * * * * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- A: statistics/dev directory catalog file and the number of the symbolic link files; Show the current system of
Environment variables,
B: file1, file2 two file (download from the classroom to send copy after home directory) turn the lowercase characters
In the capital, merge the content of the converted into a new file named after your student number four, according to the content of the new file, after the completion of the display will file1, file2 two files empty file to cutting to size of 0,
C: input a SHELL command, to test if it is the built-in commands, is a built-in command 2
Use the help command to give its help information, not the built-in command use which command to its file path,
(2) run the following program under Linux environment, combining the output analysis, understand the program, answer questions from the behind,
Routine 1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Set12345678910abcdefgh shift 2
For the index
Do
If [6] $index - le then
Echo "continue"
The continue fi
Echo $index
If [$index - ge 10] then
Echo "break"
Break fi
The done
Q1: brief description line 1 set and 2 line shift function of two commands;
Q2: line 3 for loop why there is no clause in? Q3: after modified line 5 code, making the output contains only 3 4 5 6 7 these 5 Numbers,
3
Routine 2:
1
2
3
4
5
6
7
8
9
10
11.
12
13
14
15
Oldifs="$IFS IFS"=", "
While read the line do
The count=0
For the item in $line do
[$count - eq 0] & amp; & User=$item [$count - eq 5] & amp; & Home=$item [$count - eq 6] & amp; & Dirsh=$item let count++
The done
Echo The $user, Home: $Home; Done
Shell: $dirsh
Q1: what is the role of the IFS environment variable to line 2?
Q2: line 11 after the count variable to add 1, which variable (line or item of value will be changed? Q3: understand the code 8-10 rows function, symbol "& amp; & amp;" What is in this role? Q4: modify The code, change The line 9 5 to 2, delete The line 10 and line 13 is changed to "echo The
$user and $home "after the program's output?