Remove Top Line of Text File with PowerShell

While I really admire the answer from @hoge both for a very concise technique and a wrapper function to generalize it and I encourage upvotes for it, I am compelled to comment on the other two answers that use temp files (it gnaws at me like fingernails on a chalkboard!).

Assuming the file is not huge, you can force the pipeline to operate in discrete sections–thereby obviating the need for a temp file–with judicious use of parentheses:

(Get-Content $file | Select-Object -Skip 1) | Set-Content $file

… or in short form:

(gc $file | select -Skip 1) | sc $file

Leave a Comment