linux vi向文件尾翻页,linux vi从当前行复制到文件尾的命令?

匿名用户

1级

2009-09-22 回答

基於linux 的精神,这个该用sed来做吧,假设文件这样

nc10@your-5554c55be4 ~

$ cat bin/funfacts.pl

#! /usr/bin/perl

#funfacts.pl by twfccc@gmail.com, public domain

use strict;

use warnings;

use LWP::Simple;

my $url = "http://www.cs.cmu.edu/~bingbin/";

my $fact = get($url) or die "Could not open $url: $!\n";

$fact =~ s/]+>//g;

$fact =~ s/>+//g;

my @fact = split(/\n/, $fact);

my $size = @fact;

srand();

my $random = int( rand() * $size * $$ ) % $size;

my $x = $fact[$random]?$fact[$random]:$fact[$random + 1];

print "\n$x\n\n";

我想由my $url 到文件末复制到另一文件, 这样

nc10@your-5554c55be4 ~

$ sed '/\$url/,$!d' bin/funfacts.pl

my $url = "http://www.cs.cmu.edu/~bingbin/";

my $fact = get($url) or die "Could not open $url: $!\n";

$fact =~ s/]+>//g;

$fact =~ s/>+//g;

my @fact = split(/\n/, $fact);

my $size = @fact;

srand();

my $random = int( rand() * $size * $$ ) % $size;

my $x = $fact[$random]?$fact[$random]:$fact[$random + 1];

print "\n$x\n\n";

nc10@your-5554c55be4 ~

$ sed '/\$url/,$!d' bin/funfacts.pl > somejunk

nc10@your-5554c55be4 ~

$ cat somejunk

my $url = "http://www.cs.cmu.edu/~bingbin/";

my $fact = get($url) or die "Could not open $url: $!\n";

$fact =~ s/]+>//g;

$fact =~ s/>+//g;

my @fact = split(/\n/, $fact);

my $size = @fact;

srand();

my $random = int( rand() * $size * $$ ) % $size;

my $x = $fact[$random]?$fact[$random]:$fact[$random + 1];

print "\n$x\n\n";

nc10@your-5554c55be4 ~

$

这样比用vim/vi手动快多了,且不会错,对吗?呵呵

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值