Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Powershell how to search the file and then open then tail the file based on the first search

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading