Reputation: 5
How do open tail the first text file I search in descending order?
Get-Content -Tail
Get-ChildItem -Force -Recurse -File -Path "C:\*.txt" -ErrorAction SilentlyContinue | Where-Object { $_.CreationTime.Date -lt (Get-Date).Date } | Sort CreationTime -Descending
Upvotes: 0
Views: 123
Reputation: 174515
Use Select-Object -First 1
to discard everything after the first input object:
Get-ChildItem ... |Where-Object {...} | Sort ... |Select-Object -First 1 |Get-Content -Tail
Upvotes: 2