如何删除一个文件的第一行? [英] How do I delete the first line in a file?

查看:218
本文介绍了如何删除一个文件的第一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能搜索一个特定的字符串,因为他们都非常相似,但我想简单的东西在一个文件中砍出前4行。

I can't search for a particular string, since they're all very similar, but I'd like something simple to chop out the first 4 lines in a file.

他们都变长了。我有一个想一下Perl的,而这一切似乎比我想象的困难,但我想这样做在Perl,AWK或shell命令如果可能的话。

They're all variable length too. I've had a think about perl, and it all seems harder than I thought, but I'd like to do it in Perl, AWK or a shell command if possible.

没有任何人有这样做的一个简单的方法?

Does anybody have a simple way of doing this?

推荐答案

SED 是最简单的。删除文件的第一行,这样做:

sed is the simplest. To delete the first line of a file, do:

sed '1d' file.txt

或者,要删除前四行,如下:

Or, to remove the first four lines, do:

sed '1,4d' file.txt

这篇关于如何删除一个文件的第一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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