powershell- $spLine=2; #指定在第几行之后插入
- $str="要插入的内容"; #指定要插入的内容
- dir *.txt -r|%{
- [System.Collections.ArrayList] $content=[io.file]::ReadAllLines($_.FullName,[text.encoding]::Default);
- $content.Insert($spLine,$str)
- [io.file]::WriteAllLines($_.FullName,$content,[text.encoding]::Default)
- }
复制代码
|