-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -EndOfLine character and -DiscardBlankLines parameters to Get-Content #9345
Comments
Dup #3855 |
The #3855 issue is about "delimiters" between lines. That is not what this is about. |
|
Using Perhaps there is a better terminology than |
I definitely like the feature, but I agree that "end of line" would cause confusion with "newline" , Omitting the word comment is not an option, I think, but it's tricky to come up with the right name. Let's look at
In short: Given that single-character comment sigils virtually always have consider-everything-through-the-end-of-the-current-line-a-comment semantics, I think we can actually omit that aspect in the naming, and use something like
|
Excellent analysis @mklement0. I would be good with both Could there be a switch |
Does this merit further work? What is the process to make such a change? |
@Liturgist Example in your initial post is not common enough (I mean a standards like csv or tabular data). @mklement0 also pointed out this problem. So I don't see how we could go forward. |
@iSazonov, perhaps it would be good if this were uncommon. There are many files in the world that are process in this way by cmd.exe FOR loops. WRT @mklement0's comment about unconditional striping from a -CommentChar, that could be a limitation of the mechanism. I am not sure as to the difficulty of parsing quoted text since I would not call myself a language guy. I would think that it is well-known. What would doing "tablular data" mean? Are you saying that only tab-delimited files could be used? |
In short mentioned above standard generalizes CSV format so that you can use any delimiters for "fields" and "lines". I believe it solves part of what you ask. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
2 similar comments
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
📣 Hey @Liturgist, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://forms.office.com/r/P926k48jRJ |
Summary of the new feature/enhancement
It would be helpful to have an -EndOfLine character parameter in order to read files which use a character to indicate the start of comments.
I want to read a file containing a list of computernames grouped by department. I want to be able to have comment lines to name the groups as well as omit some servers which are known to be unavailable.
Using this list, the following does not work well.
Test-Connection -Computername (Get-Content -Path './hosts.txt') -Count 1
I realize that I could filter them explicitly.
Test-Connection -Computername (Get-Content -Path '.\hosts.txt' | ForEach-Object { if (($_ -ne '') -and ($_[0] -ne '#')) { $_ }})
I would like to use:
Test-Connection -Computername (Get-Content -Path '.\hosts.txt' -EndOfLine '#' -DiscardBlankLines)
The text was updated successfully, but these errors were encountered: