ChinaUnix.net
相关文章推荐:

shell读文件

现在有下面这样的log文件。 id100 abkjjkl start get timestamp 34 xxxxxxjfkdjsl id101 ahhjj start get timestamp 35 id100 ueiuot stop get timestamp 37 xxxxxxjfkdjsl id101 jklfjds stop get timestamp 46 id100 uuioruew start get timestamp 56 ....... 我要实现的是,读取所有id100,id101...idxxx中,start与stop之间的时间差。 现在的问题是, 读取有id100的行中,start get 中的 时间 (34) 然后继续读...

by robbyzi - Linux环境编程 - 2010-03-20 09:55:30 阅读(1455) 回复(4)

相关讨论

shell脚本读文件 . 先说一下,我用的是这个: 以下是sh文件内容[code] ******************************************** #!/bin/sh FILENAME="$1" cat $FILENAME | while read LINE do echo "$LINE" done ******************************************** 给你写了一个小例子,从一个文件读数据,设置环境变量: 数据文件data.txt包含三行: aaa bbb ccc ------ test.sh ------ while read data;...

运维

by 凝望长空 - 监控及自动化运维技术 - 2011-11-19 10:28:24 阅读(1682) 回复(2)

我的文件里面有这么一句话 Version: 2.0.0.020 我想通过shell把版本号读取出来,怎么用grep和sed

by yellowweng - Shell - 2008-08-29 10:55:05 阅读(2069) 回复(2)

想用shell来解析一个大约500M的文件,希望能尽量高效,不知道有什么好的方法。 1)将文件直接读入内存是不是可以cat $FILE_NAME | while read $LINE,还有什么方式,这种方法除了占用内存有什么优劣? 2)那下面的两种方式又有什么优劣,原因是什么呢? 3)shell读大文件较好的方法有那些? 谢谢大家了! [code] function while_read_LINE_FD { exec 3<&0 exec 0< $FILENAME while read LINE do echo "$LINE" : d...

by IAMTOP1982 - Shell - 2008-06-23 09:24:42 阅读(2109) 回复(1)

我有个文件dtm.txt内容如下: $ danaec sample01.csv test_a01.dtm --ADSF output_a01a.dsf --AHTM output_a01a.html $ danaec sample22.csv test_a02.dtm --ADSF output_a02a.dsf --AHTM output_a02a.html $ danaec sample30.csv test_a13.dtm --ADSF output_a03a.dsf --AHTM output_a03a.html ........ 我的要求是:读第一行,找到字符串“sample01.csv ”,找到字符串“test_a01.dtm ”,找到字符串“output_a01a.dsf ...

by chunshan - Shell - 2003-08-15 14:34:43 阅读(8917) 回复(4)

我有个文件dtm.txt内容如下: $ danaec sample01.csv test_a01.dtm --ADSF output_a01a.dsf --AHTM output_a01a.html $ danaec sample22.csv test_a02.dtm --ADSF output_a02a.dsf --AHTM output_a02a.html $ danaec sample30.csv test_a13.dtm --ADSF output_a03a.dsf --AHTM output_a03a.html ........ 我的要求是:读第一行,找到字符串“sample01.csv ”,找到字符串“test_a01.dtm ”,找到字符串“output_a01a.dsf ”,...

by chunshan - Linux论坛 - 2003-08-13 19:03:03 阅读(1415) 回复(2)

linux上面, cat /etc/infile | read strLine /etc/infile 里面就一行,长度2K, 结果读出来,我用${#strLine}看了看长度,只有1538 有办法整行读出来吗? 谢谢

by tena - Shell - 2011-07-19 14:06:06 阅读(2663) 回复(1)

[code] filename=s.dat new_user="NEW" unused_user="UNUSEED" useable_user="USEABLE" i=0 while read name type do tmp=`echo $type|sed 's/\r//g'` if [ "$tmp" = "NEW" ] then sed "s/USER/$name/" t.dat fi done < $filename[/code]每次读都不读最后一行数据,但是如果我在在后一行敲回车换到一个空行后,最后一行就可以读出来。 请指教一二,好久好久没看shell了,哎。

by 秋池飞叶 - Shell - 2011-05-03 10:52:34 阅读(3646) 回复(3)

以KSH为例: [code]#!/usr/bin/ksh # # SCRIPT: 12_ways_to_parse.ksh.ksh # # # REV: 1.2.A # # PURPOSE: This script shows the different ways of reading # a file line by line. Again there is not just one way # to read a file line by line and some are faster than # others and some are more intuitive than others. # # REV LIST: # # 03/15/2002 - Randy Michael # Set each of t...

by dbcat - Shell - 2007-08-16 10:54:04 阅读(15676) 回复(15)

文件名pn.txt 里边放的手机号码格式如下: 138xxxxxx 136xxxxxx 136xxxxxx 139xxxxxx ..... 137xxxxxx 目的是想用shell脚本写一个循环把pn.txt的手机号码读到变量里边去,以便做劲一步的比较! 网上找了半天,没找到几个shell编程的示例,大家有知道的给介绍一下,让俺多研究一下示例 谢谢各位

by 西门子 - Shell - 2005-05-18 13:06:15 阅读(1208) 回复(2)

我有个文件dtm.txt内容如下: $ danaec sample01.csv test_a01.dtm --ADSF output_a01a.dsf --AHTM output_a01a.html $ danaec sample22.csv test_a02.dtm --ADSF output_a02a.dsf --AHTM output_a02a.html $ danaec sample30.csv test_a13.dtm --ADSF output_a03a.dsf --AHTM output_a03a.html ........ 我的要求是:读第一行,找到字符串“sample01.csv ”,找到字符串“test_a01.dtm ”,找到字符串“output_a01a.dsf ”,...

by chunshan - Linux系统管理 - 2003-08-13 19:03:03 阅读(1894) 回复(2)