unix shell 通过两个行号获取文件内容 比如获取1.log文件的10000行到20000行 请问怎么写 请高手赐教 谢谢

找个文件()里面一行1个中文名字。一共10000个。

something like this

sed -n '10000,20000p' yourfile

testing

User@User-PC ~
$ sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.

User@User-PC ~
$ cat bin/temperature
#! /usr/bin/perl

use strict;
use warnings;
use LWP::Simple;

my ($url, $content, @x, $x, @y);

$url = "";
$content = get($url) or die;
@x = split /\n/, $content;
@y = grep /^[\w\d]+/, @x;
$x = join "\n", @y;
$x =~ s/<[^>]+>//g;
print "$x\n"

User@User-PC ~
$ sed -n '3,9p' bin/temperature
use strict;
use warnings;
use LWP::Simple;

my ($url, $content, @x, $x, @y);

$url = "";

User@User-PC ~
$

User@User-PC ~
$ wc -l < mil-dic.txt
83337

User@User-PC ~
$ sed '10000,20000!d' mil-dic.txt

<skipped>

97fa7920
97jetta
97probe
98
980108042
980125
9803735395
980381
980480
980517
9805d4
9807013131

User@User-PC ~
$

OK? :)
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-02-28
sed -n 10000,20000p 1.log
第2个回答  2011-02-27
SPLIT 命令就可以搞定