用于从多个 TXT 文件中删除标题行的命令行脚本

发布于 2024-09-15 23:13:29 字数 38 浏览 1 评论 0原文

从大型(10k+)文本文件组中删除第一行文本的最佳方法是什么?

What's the best method to delete the first line of text from a large (10k+) group of text files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

栖迟 2024-09-22 23:13:29

如果 PowerShell 不可行,您可以使用 more 命令:

more [file] +2 > [new file]

将其放入 for 循环中,然后重命名[新文件][file] ,您将得到减去第一行的文件。

不漂亮,但应该可以。

If PowerShell isn't an option, you can use the more command:

more [file] +2 > [new file]

Stick that in a for loop that also then renames [new file] to [file] and you'll have the file minus the first line.

Not pretty, but should work.

花落人断肠 2024-09-22 23:13:29

如果您可以在系统中安装TAIL

tail -n +2 filename > finalfilename

则会显示除第一行之外的所有文件名。

在我看来,Windows CMD 并不是最好的“终端”。但是,您不需要 tail 命令。正如 Patrick Cuff 所说,您可以使用 more 命令,其作用基本相同。

我认为这是使用内置命令的最佳答案。

如果您对编程有所了解,您可以编写一个小程序来执行您想要的操作并在 bat 文件中调用它。

此外,您还可以使用其他 Windows 终端,例如 cygwinpowershell控制台具有更灵活的内置命令来执行此类操作。

If you can install TAIL in your sistem

tail -n +2 filename > finalfilename

shows all the filename except the first line.

The windows CMD, in my opinion, isn't the best "terminal". However, you don't need tail command. As Patrick Cuff said, you cand use the more command that does basically the same.

I think that is the best answer to do with buil-in commands.

If you know a bit about programming, you can make a small program that does what you want and call it in a bat file.

Also, you can use other windows terminals like cygwin, powershell or console that have more flexible built in commands to do this kind of stuff.

﹂绝世的画 2024-09-22 23:13:29

如果使用 PowerShell 是您可以从这篇文章中采用的选项:删除顶行使用 Powershell 的文本文件

If using PowerShell is an option you could adopt from this post: Remove Top Line of Text File with Powershell

空城仅有旧梦在 2024-09-22 23:13:29

下载Windows 版 sed。然后

c:\test> sed -i.bak "1d" file

使用 for 循环来迭代文件

download sed for windows. Then do this

c:\test> sed -i.bak "1d" file

use a for loop to iterate files

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文