- 论坛徽章:
- 0
|
1 #!/bin/bash
2 # poem.sh: 将本书作者非常喜欢的一首诗, 漂亮的打印出来.
3
4 # 诗的行数(单节).
5 Line[1]="I do not know which to prefer,"
6 Line[2]="The beauty of inflections"
7 Line[3]="Or the beauty of innuendoes,"
8 Line[4]="The blackbird whistling"
9 Line[5]="Or just after."
10
11 # 出处.
12 Attrib[1]=" Wallace Stevens"
13 Attrib[2]=""Thirteen Ways of Looking at a Blackbird""
14 # 这首诗已经是公共版权了(版权已经过期了).
15
16 echo
17
18 for index in 1 2 3 4 5 # 5行.
19 do
20 printf " %sn" "${Line[index]}"
21 done
22
23 for index in 1 2 # 出处为2行.
24 do
25 printf " %sn" "${Attrib[index]}"
26 done
27
28 echo
29
30 exit 0
31
32 # 练习:
33 # -----
34 # 修改这个脚本, 使其能够从一个文本数据文件中提取出一首诗的内容, 然后将其漂亮的打印出来.
|
如上述代码的20行和25行,代码是从书上来的,应该没错,但我在Fedroa是跑出却说bash找不到printf命令~~ |
|