unix 命令通过传递行号从文件中读取行 [英] unix command to read line from a file by passing line number

查看:30
本文介绍了unix 命令通过传递行号从文件中读取行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个 unix 命令,通过将行号传递给一个大文件(大约有 500 万条记录)来获取一行.例如要获得第 10 行,我想做类似

I am looking for a unix command to get a single line by passing line number to a big file (with around 5 million records). For example to get 10th line, I want to do something like

command file-name 10

有这样的命令吗?我们可以通过遍历每条记录来做到这一点,但这将是一个耗时的过程.

Is there any such command available? We can do this by looping through each record but that will be time consuming process.

推荐答案

This 论坛条目 建议:

sed -n '52p' (file)

用于打印文件的第 52 行.

for printing the 52th line of a file.

这篇关于unix 命令通过传递行号从文件中读取行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆