写个脚本随机读取指定文件的若干行内容并写到指定文件内

用pathon,awk,java程序也行,随机读若干行,运行环境为linux。。

都是能顺序读取,读取后,要不要,你自己随机决定一下就行了
或者你全部读出来到List,然后随机取index,取出来

 #coding=utf-8
#! /usr/bin/python
import random
import linecache
def hello():
    count = len(open('hello.txt','rU').readlines())#获取行数
    hellonum=random.randrange(1,count, 1)#生成随机行数
    return linecache.getline('hello.txt',hellonum)#随机读取某行
if __name__ == "__main__":
    hello()