Skip to content

Commit

Permalink
docs(read): edit example
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanyf committed Jun 21, 2020
1 parent b68dfda commit 87a354b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/read.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ REPLY = 'a b c d'
`read`命令除了读取键盘输入,可以用来读取文件。

```bash
#!/bin/bash

filename='/etc/hosts'

while read myline
do
echo "$myline"
done < $filename
```

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

## 参数

Expand Down

0 comments on commit 87a354b

Please sign in to comment.