7

Perl 倒行分析文件方法。perl读文本文件,从末尾往前读.

 2 years ago
source link: https://blogread.cn/it/article/531?f=hot1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
您现在的位置首页 --> 其他 --> Perl 倒行分析文件方法。perl读文本文件,从末尾往前读.

Perl 倒行分析文件方法。perl读文本文件,从末尾往前读.

浏览:4046次  出处信息

1.用 File::ReadBackwards :
http://search.cpan.org/~uri/File-ReadBackwards-1.04/ReadBackwards.pm

2. 用管道:

以下是代码片段:
open my $F1, ” XXX cmd | “ ; 
 while(<$F1>) {
…}该管道和命令输出是同步的,和|tee类似

3.seek,tell也可以啊,自己可以控制

4.用tail是可以的,但是不太好估计tail多少行,tail N行->判断->tail 2N行 貌似可以动态判断,但比较繁琐,个人不赞成

5.从前面正向读的话觉得读了前面一堆没有必要的行,文件大了会很慢,循环里面有一堆正则处理的东西

6.用tac file | 然后读管道,貌似比较不错,但不是很清楚所有server上是否都有tac命令,而且也不知道性能怎样?

建议继续学习:

QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK