1. you want to download a software from the server, your machine has two network cards eth0 and eth1, the address is configured as follows:
Eth0 : 192.168.6.25/24
Eth1 : 172.16.101.25/24
default gateway: 192.168.6.1/24
server address:211.138.18.30
At this point, you find that your machine has two routing entries:
Destination Gateway genmask Flags MSS Window Irtt Iface
211.138.0.0 * 255.255.0.0 U 0 0 0 eth0
211.138.16.0 * 255.255.240.0 U 0 0 0 eth1
Excuse me: Your machine to the server to download software, how will choose the way, why?
Solution: Choose eth1 according to the principle of minimization. Can be precisely matched to exact match, can not precisely match the board to go large segment
Detailed Description :
A machine has two network cards eth0 and eth1, to access the 211.138.18.30 server, according to the principle of minimization will first match the minimum network segment, if the minimum network segment mismatch, and then match the maximum network segment.
By the problem know 211.138.16.0 do subnetting, with Ipcalc tool can analyze:
wget #或者自己从网上下载一个ipcalc工具 chmod +x ipcalc ./ipcalc 211.138.16.0 255.255.240.0address: 211.138.16.0 11010011.10001010.0001 0000.00000000netmask: 255.255.240.0 = 20 11111111.11111111.1111 0000.00000000Wildcard: 0.0.15.255 00000000.00000000.0000 1111.11111111=>network: 211.138.16.0/20 11010011.10001010.0001 0000.00000000hostmin: 211.138.16.1 11010011.10001010.0001 0000.00000001hostmax: 211.138.31.254 11010011.10001010.0001 1111.11111110Broadcast: 211.138.31.255 11010011.10001010.0001 1111.11111111hosts/net: 4094 class c
Note: The network segment is 211.138.16.0/20, the minimum network segment is from 211.138.16.1 to 211.138.31.254, can match to the server address 211.138.18.30, so the machine goes to the server download software will choose Eth1
2. use shell or Perl to write a right-angled trapezoid program (a.sh)to receive user input parameters n,m
Example:a.sh 4 6
* * * *
* * * * *
* * * * * *
Answer:
Script one:
[Email protected] 2015-12-01]# sh a.sh
****
*****
******
[[email protected] 2015-12-01]# cat a.sh #/bin/shfor i in ' SEQ 4 6 ' Does for J in ' seq $i ' doecho-n ' * ' done echo Done
Script two:
[[Email protected] 2015-12-01]# SH t.sh 4 6
* * * *
* * * * *
* * * * * *
[[email protected] 2015-12-01]# cat t.sh #!/bin/bashif [$#-ne 2];thenecho "Error!!!" EXITFIIF [$1-gt $];theni=$2j=$1elsei=$1j=$2fifor m in ' seq $i $j ';d ostr= ' for i in ' seq 1 $m ';d ostr= "$str \t*" Doneecho $str | Sed ' s/\\t//g ' done
Script Three:
[[Email protected] 2015-12-01]# SH h.sh 4 6
* * * *
* * * * *
* * * * * *
[[email protected] 2015-12-01]# cat h.sh #!/bin/bashif [$#-ne 2];thenecho "Error!!!" EXITFIIF [$1-gt $];theni=$2j=$1elsei=$1j=$2fifor m in ' seq $i $j ';d ostr= ' for i in ' seq 1 $m ';d ostr= "$str \t*" Doneecho $str | Sed ' s/\\t//g ' done
Report:
[[email protected] 2015-12-01]# SEQ 3
1
2
3
[[email protected] 2015-12-01]# for I in $ (seq 3);d o echo $ (seq 3);d One
1 2 3
1 2 3
1 2 3
Output 10 lines, 3 digits per line
[[email protected] 2015-12-01]# for I in $ (seq);d o echo $ (seq 3);d One
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
Output 10 lines, 10 digits per line
[[email protected] 2015-12-01]# for I in $ (seq);d o echo $ (seq);d One
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
[Email protected] 2015-12-01]# tstr= ""; for ((i = 0; i <; i++)); Do echo "$tstr *"; Tstr= "$tstr *"; Done
*
**
***
****
*****
******
*******
********
*********
**********
Script Output Right angle trapezoid:
#/bin/shfor i in ' seq 3 5 ' does Forj in ' seq $i ' does echo-n ' * ' Done echodone
To receive user input parameters:
#/bin/shwhile truedo echo-n "pls enter the number:" $1 "$ $ read line sleep echo" $line "done
By the way, share the shell I picked up. Learning methods:
Http://www.chinaunix.net/old_jh/24/312462.html
Shell synthesis level test questions:
Http://bbs.chinaunix.net/thread-476260-1-1.html
http://oldboy.blog.51cto.com/2561410/1718607
The knife does not grind to rust.
This article is from the "Lanzhi" blog, make sure to keep this source http://7826443.blog.51cto.com/7816443/1718704
shell< two >