Skip to content

Commit 87a354b

Browse files
committed
docs(read): edit example
1 parent b68dfda commit 87a354b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

docs/read.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,17 @@ REPLY = 'a b c d'
6464
`read`命令除了读取键盘输入,可以用来读取文件。
6565

6666
```bash
67+
#!/bin/bash
68+
69+
filename='/etc/hosts'
70+
6771
while read myline
6872
do
6973
echo "$myline"
7074
done < $filename
7175
```
7276

73-
上面的例子通过`read`命令,读取一个文件的内容。`done`命令后面的定向符`<`将文件导向`read`命令,每次读取一行,存入变量`myline`,直到文件读取完毕。
77+
上面的例子通过`read`命令,读取一个文件的内容。`done`命令后面的定向符`<`将文件内容导向`read`命令,每次读取一行,存入变量`myline`,直到文件读取完毕。
7478

7579
## 参数
7680

0 commit comments

Comments
 (0)