文件名 test28.sh

#!/bin bash
# reading data from a file count=
cat test | while read line
do
echo "Line $count:$line"
count=$[ $count + ]
done
echo "Finshed processing the file"

test文件内内容为:

The quick brown dog jumps over the lazy fox.
This is a test,this is only a test.

运行 sh test28.sh

输出:

Line :The quick brown dog jumps over the lazy fox.
Line :This is a test,this is only a test.

read 读取文件内容的更多相关文章

  1. shell读取文件内容

           Shell脚本,执行解释速度快.代码简单易于理解.在shell代码编写过程中,经常会用到读取文件内容. 写法一: ------------------------------------ ...

  2. Python跳过第一行读取文件内容

    Python编程时,经常需要跳过第一行读取文件内容.比较容易想到是为每行设置一个line_num,然后判断line_num是否为1,如果不等于1,则进行读取操作.相应的Python代码如下: inpu ...

  3. 用c#读取文件内容中文是乱码的解决方法:

    用c#读取文件内容中文是乱码的解决方法: //方法1: StreamReader din = new StreamReader(@"C:\1.txt", System.Text.E ...

  4. android按行读取文件内容的几个方法

    一.简单版 import java.io.FileInputStream; void readFileOnLine(){ String strFileName = "Filename.txt ...

  5. android逐行读取文件内容以及保存为文件

    用于长时间使用的apk,并且有规律性的数据 1,逐行读取文件内容 //首先定义一个数据类型,用于保存读取文件的内容 class WeightRecord { String timestamp; flo ...

  6. 7 RandomAccessFile读取文件内容保存--简单例子(需要验证)

    import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; /** * 读取动态产生的文件内容 */ publ ...

  7. shell读取文件内容并进行变量赋值

    需求: shell读取文件内容,然后把内容赋值给变量然后进行字符串处理 实现: dataline=$(cat /root/data/data.txt) echo $dataline

  8. node遍历文件夹并读取文件内容

    var fs = require('fs'); var path = require('path');//解析需要遍历的文件夹 var filePath = path.resolve('./dist' ...

  9. 使用while和read命令读取文件内容

    转:使用while和read命令读取文件内容 1.准备数据文件 $cat a.txt 200:2 300:3 400:4 500:5 2.用while循环从文件中读取数据 #!/bin/ksh whi ...

  10. Node.js读取文件内容

    原文链接:http://blog.csdn.net/zk437092645/article/details/9231787 Node.js读取文件内容包括同步和异步两种方式. 1.同步读取,调用的是r ...

随机推荐

  1. libsqlite3.dylib找不到

    Xcode7中 Link Binary With Libraries 没有 .dylib库,只能找到对应的 .tbd,但不能代替使用,通过查找资料,尝试后得到以下两种解决方法. 方法1. (heqin ...

  2. symfony中twig的模板载入

    模板 载入模板 {% include ‘sidebar.html’ %} 当前模板的变量也会传递到 被include的模板里,在那里面可以直接访问你这个模板的变量. {% for comment in ...

  3. ecshop简单三部实现导航分类二级菜单

    1.在page_header.lbi对应的位置(你想显示导航的位置)插入 (注意下面的"themes/模板名称/util.php"中的"模板名称"改成你模板文件 ...

  4. ecshop后台增加模板页的方法

    CShop的动态模板机制是一个非常灵活的系统,管理员可以在后台根据自己的要求调整模板模块的显示位置.本文详细讲解了如何修改ECSHOP内部结构使得用户可以添加自己的模板页从而方便灵活的使用系统自带的模 ...

  5. vsftpd

    vi /etc/vsftpd.conf and add the following allow_writeable_chroot=YES sudo service vsftpd restart

  6. 第十一章 Android 内核驱动——Alarm

    11.1  基本原理 Alarm 闹钟是 android 系统中在标准 RTC 驱动上开发的一个新的驱动,提供了一个定时器 用于把设备从睡眠状态唤醒,当然因为它是依赖 RTC 驱动的,所以它同时还可以 ...

  7. Communication System(dp)

    Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 25006 Accepted: 8925 ...

  8. 软件测试工作中涉及的Linux命令整理

    Linux文件系统命令 1. 安装火狐浏览器,首先得知道Linux系统是64位的还是32位的 uname -a 2. 将下载的火狐浏览器压缩包移动到指定目录(/user/local)下 sudo mv ...

  9. 遍历对象的list删除时报错问题。

    我们对一个对象的list或者map进行删除操作时,可能会这么写 for(Distributor distributor:distributorList){ String distributorShor ...

  10. Codeforces Round #260 (Div. 2) A

    Description One day Dima and Alex had an argument about the price and quality of laptops. Dima think ...