Linux中的Shell脚本逐行读取文件的4种方法
2016-12-19 16:24
681 查看
1.釜底抽薪法
while循环中执行效率最高,最常用的方法function while_read_LINE_bottm(){ While read LINE do echo $LINE done < $FILENAME }
2.重定向法
Function While_read_LINE(){cat $FILENAME | while read LINE
do
echo $LINE
done
}
3.文件描述符法
Function while_read_line_fd(){ Exec 3<&0 Exec 0<$FILENAME While read LINE Do Echo $LINE Exec 0<&<3 }
4.for循环
function for_in_file(){
For i in `cat $FILENAME`
do
echo $i
done
}
相关文章推荐
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法
- Linux中执行shell脚本的4种方法总结
- shell脚本从文件中按行读取数据,并且赋值到数组中的几种方法
- Linux中执行shell脚本的4种方法总结
- 通过shell脚本实现从文件中读取数据的几种方法
- shell 脚本逐行读取多个文件,并逐行对应
- Linux中执行shell脚本的4种方法
- Linux中执行shell脚本的4种方法总结
- Linux中执行shell脚本的4种方法总结
- 每天一个linux命令(62):sh命令 /Linux中执行shell脚本的4种方法总结
- 【linux】执行shell脚本的4种方法总结