查看用数字表示的文件的特定行 [英] view a particular line of a file denoted by a number

查看:91
本文介绍了查看用数字表示的文件的特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这可能是显而易见的事情,但是它使我无所适从,因为到目前为止,它可能以一种我还不知道的更简单的方式来完成. 假设有一个文件",而我只想查看该文件的行号"X"上的内容,解决方案是什么?

Okay, this is probably an evident thing but it escapes me, as in it could probably be done in a much simpler way that I'm not aware of, so far.. Say there's a "file" and I want to view only what's on line number "X" of that file, what would be the solution?

这是我能想到的:

head -X < file | tail -1  
 sed -n Xp < file

unix/gnu/linux text-tools/utils的标准集中还有其他(或其他方式)吗?

is there anything else (or any other way) from the standard set of unix/gnu/linux text-tools/utils?

推荐答案

sed -n 'Xp' theFile,其中X是您的行号,而theFile是您的文件.

sed -n 'Xp' theFile, where X is your line number and theFile is your file.

这篇关于查看用数字表示的文件的特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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