You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default Get-Content (and switch -File) streams lines on either CR, CRLF, or LF newlines, which is a good thing as it allows to interchange (large) text files between Operating Systems. The point is though that in some cases a more specific line terminator is required (e.g. only a CRLF) which could possible lead to not being able to stream lines (using standard cmdlets to prevent out of memory exceptions) if it concerns very large text files.
See: StackOverflow Powershell - Count number of carriage returns line feed in .txt file
An additional Parameter as -Newline <string> (e.g. -Newline "`r`n") could resolve this and might also allow to stream a (large) text file on a completely different character (combination) as e.g. a tab: -Newline "`t".
Note that Get-Content already has a -Delimiter parameter that serves this purpose: it accepts any literal string as the string to split the file content by, using terminator logic rather than separator logic (that is, if the content ends in the given string, no additional, empty element is reported).
-Delimiter is a dynamic parameter of the FileSystem provider.
By default
Get-Content
(andswitch -File
) streams lines on either CR, CRLF, or LF newlines, which is a good thing as it allows to interchange (large) text files between Operating Systems. The point is though that in some cases a more specific line terminator is required (e.g. only aCRLF
) which could possible lead to not being able to stream lines (using standard cmdlets to prevent out of memory exceptions) if it concerns very large text files.See: StackOverflow Powershell - Count number of carriage returns line feed in .txt file
An additional Parameter as
-Newline <string>
(e.g.-Newline "`r`n"
) could resolve this and might also allow to stream a (large) text file on a completely different character (combination) as e.g. a tab:-Newline "`t"
.Related
Out-String -Stream
unexpectedly does not split multi-line input strings into individual lines too #14638Out-String -Stream
unexpectedly does not split multi-line input strings into individual lines tooThe text was updated successfully, but these errors were encountered: