使用 PowerShell 删除文本文件的首行 [英] Remove Top Line of Text File with PowerShell
本文介绍了使用 PowerShell 删除文本文件的首行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在导入之前删除大约 5000 个文本文件的第一行.
I am trying to just remove the first line of about 5000 text files before importing them.
我对 PowerShell 还是很陌生,所以不确定要搜索什么或如何解决这个问题.我目前使用伪代码的概念:
I am still very new to PowerShell so not sure what to search for or how to approach this. My current concept using pseudo-code:
set-content file (get-content unless line contains amount)
但是,我似乎无法弄清楚如何执行包含之类的操作.
However, I can't seem to figure out how to do something like contains.
推荐答案
它不是世界上最高效的,但它应该有效:
It is not the most efficient in the world, but this should work:
get-content $file |
select -Skip 1 |
set-content "$file-temp"
move "$file-temp" $file -Force
这篇关于使用 PowerShell 删除文本文件的首行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文