1.使用for循环

for line in `cat filename`
do
echo $line
done

  

2.使用for循环

for line in $(cat filename)
do
echo $line
done

  

3.使用while循环

while read -r line
do
echo $line
done < filename

  

Shell脚本循环读取文件中的每一行的更多相关文章

  1. shell脚本循环处理文件数据

    有一个日志文件为: # cat data.log 需要提取出里面的数据,写shell脚本实现这个功能: #!/bin/bash OLD=$IFS IFS=$'\n' for entry in $(ca ...

  2. shell 脚本sed替换文件中某个字符串

    有些大文件,特别的大.有几百兆,甚至更大. 用文本编辑器打开十分的费劲,电脑都卡死了. 想替换其中的字符串,很麻烦. 这个时候有了shell,简直强大到爆炸! # du -h user.sql 304 ...

  3. Java 读取文件中的每一行,并为每一行插入特定的字符串

    工具 1:Eclipse Java EE IDE for Web Developers. Version: Photon Release (4.8.0). Build id: 20180619-120 ...

  4. shell 脚本,提取文件中的内容

    使用awk.cut.sed.if.while 等 awk.cut.sed还是很重要的 这是后来修改的,可以完成 #!/bin/bash #conver formatFILE=mobile_dpi.ru ...

  5. shell脚本,如果文件中的第一列有相同的,就把相同的那些行的其他字段相加

    命令:awk '{a[$1]+=$2}{b[$1]+=$3}END{for(i in a){print i,a[i],b[i]}}'

  6. 【转】Java从hdfs上读取文件中的某一行

    [From]https://blog.csdn.net/u010989078/article/details/51790166 package test; import java.io.Buffere ...

  7. shell awk读取文件中的指定行的指定字段

    1.awk功能和实用形式 awk指定读取文件中的某一行的某个字段 awk      可以设置条件来输出文件中m行到n行中每行的指定的k字段,使用格式如下 awk    'NR==m,NR==n {pr ...

  8. Mac下通过shell脚本修改properties文件

    通过shell脚本替换属性文件中的某行记录 假设有如下属性文件 demo.properties user.name=test user.password=123456 ................ ...

  9. shell脚本实现读取一个文件中的某一列,并进行循环处理

    shell脚本实现读取一个文件中的某一列,并进行循环处理 1) for循环 #!bin/bash if [ ! -f "userlist.txt" ]; then echo &qu ...

随机推荐

  1. New Year and Old Property :dfs

    题目描述: Limak is a little polar bear. He has recently learnt about the binary system. He noticed that ...

  2. 初步了解CUDA(零)

    初步了解CUDA,从历史开始,先不开发:

  3. LiveVideoStack Meet|深圳 多媒体开发新趋势

    2018年初始,音视频技术生态并不平静,Codec争夺愈加激烈,新一代标准的挑战一浪高过一浪:WebRTC的定版也为打通浏览器.移动端乃至IoT带来了机会:此外AI.区块链技术的兴起,催化着与多媒体领 ...

  4. LeetCode - 13. Roman to Integer - 思考if-else与switch的比较 - ( C++ ) - 解题报告

    1.题目: 原题:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range ...

  5. C#通过gridview导出excel

    [CustomAuthorize]        public FileResult ExportQuestionCenterExcel(SearchBaseQuestion search)      ...

  6. SPOJ 8073 The area of the union of circles(计算几何の圆并)(CIRU)

    Description You are given N circles and expected to calculate the area of the union of the circles ! ...

  7. 《javascript模式--by Stoyan Stefanov》书摘--字面量和构造函数

    二.字面量和构造函数 1,能够使用对象字面量时,就没理由使用new Object构造函数 // 一个空对象var 0 = new Object();console.log( o.constructor ...

  8. Daily Scrum8

    今天我们小组开会内容分为以下部分: part 1: 说明了search.match.upload.download功能实现流程: part 2:针对用户积分模块的任务分配: ◆Part 1 searc ...

  9. Android 开发 之 JNI入门 - NDK从入门到精通

    NDK项目源码地址 : -- 第一个JNI示例程序下载 : GitHub - https://github.com/han1202012/NDKHelloworld.git -- Java传递参数给C ...

  10. Internet History,Tecchnology and Security

    Internet History Internet Technologe Internet Secure