Ignoring Empty Lines
Reading Text Files and Skipping Blank Lines To read in a text file and skip blank lines, try this: $file = 'c:\sometextfile.txt' Get-Content $file |...
- Written By: ps1
- Last Updated: April 22, 2025
- 1 minute read
Reading Text Files and Skipping Blank Lines To read in a text file and skip blank lines, try this: $file = 'c:\sometextfile.txt' Get-Content $file |...
To read in a text file and skip blank lines, try this:
$file = 'c:\sometextfile.txt' Get-Content $file | Where-Object { $_.Trim() -ne '' }
It will omit empty lines, lines with only blanks and lines with only tabs.
Contact our sales team to get a personalized demo of our database management software for SQL Server!