用于从多个 TXT 文件中删除标题行的命令行脚本
从大型(10k+)文本文件组中删除第一行文本的最佳方法是什么?
What's the best method to delete the first line of text from a large (10k+) group of text files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果 PowerShell 不可行,您可以使用
more
命令:将其放入
for
循环中,然后重命名[新文件]
到[file]
,您将得到减去第一行的文件。不漂亮,但应该可以。
If PowerShell isn't an option, you can use the
more
command: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.
如果您可以在系统中安装TAIL,
则会显示除第一行之外的所有文件名。
在我看来,Windows CMD 并不是最好的“终端”。但是,您不需要
tail
命令。正如 Patrick Cuff 所说,您可以使用more
命令,其作用基本相同。我认为这是使用内置命令的最佳答案。
如果您对编程有所了解,您可以编写一个小程序来执行您想要的操作并在 bat 文件中调用它。
此外,您还可以使用其他 Windows 终端,例如 cygwin、powershell 或 控制台具有更灵活的内置命令来执行此类操作。
If you can install TAIL in your sistem
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 themore
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.
如果使用 PowerShell 是您可以从这篇文章中采用的选项:删除顶行使用 Powershell 的文本文件
If using PowerShell is an option you could adopt from this post: Remove Top Line of Text File with Powershell
下载Windows 版 sed。然后
使用 for 循环来迭代文件
download sed for windows. Then do this
use a for loop to iterate files