duguhaotian / duguhaotian.github.io

static blog site
0 stars 0 forks source link

Shell逐行遍历文件 | Haozi007 #9

Open duguhaotian opened 4 years ago

duguhaotian commented 4 years ago

https://duguhaotian.github.io/2017/05/07/linux/shells/shell_learn_readfile_lines/

作者: 耗子007while readread命令接收标准输入,或其他文件描述符的输入,得到输入后,read命令将数据放入一个标准变量中.利用read读取文件时,每次调用read命令都会读取文件中的”一行”文本.当文件没有可读的行时,read命令将以非零状态退出.123456789cat filename| while read linedoecho “${line}”done