Title: Add parameter -Delimiter to Set-Content, Out-File, Out-String to complement Get-Content -Delimiter · Issue #3855 · PowerShell/PowerShell · GitHub
Open Graph Title: Add parameter -Delimiter to Set-Content, Out-File, Out-String to complement Get-Content -Delimiter · Issue #3855 · PowerShell/PowerShell
X Title: Add parameter -Delimiter to Set-Content, Out-File, Out-String to complement Get-Content -Delimiter · Issue #3855 · PowerShell/PowerShell
Description: Get-Content -Delimiter can be used to read text records with an arbitrary (literally matching) terminator into an array of strings, as an alternative to reading line by line. To complement this functionality, the general-purpose text-out...
Open Graph Description: Get-Content -Delimiter can be used to read text records with an arbitrary (literally matching) terminator into an array of strings, as an alternative to reading line by line. To complement this fun...
X Description: Get-Content -Delimiter can be used to read text records with an arbitrary (literally matching) terminator into an array of strings, as an alternative to reading line by line. To complement this fun...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3855
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add parameter -Delimiter to Set-Content, Out-File, Out-String to complement Get-Content -Delimiter","articleBody":"`Get-Content -Delimiter` can be used to read text records with an arbitrary (literally matching) terminator into an array of strings, as an alternative to reading line by line.\r\n\r\nTo complement this functionality, the general-purpose text-_outputting_ cmdlets should support the same parameter for _creating_ such files:\r\n\r\n* `Set-Content` / `Add-Content`\r\n* `Out-File`\r\n* `Out-String`\r\n\r\n(`ConvertTo-Csv` and `Export-Csv` already have a `-Delimiter` parameter, but there it is a _field_ separator (line-internal), and a newline is implied as the _record_ separator.)\r\n\r\nNote:\r\n\r\n* `-Delimiter ''` would effectively behave the same way as `-NoNewline` (which is currently missing from `Out-String` - see #3684).\r\n\r\n* `` -Delimiter \"`n\" `` on Windows and `` -Delimiter \"`r`n\" `` on Unix would then allow creating text files with the respective other platform's newline sequence on demand - which would also cover #2145.\r\n\r\n * The term _delimiter_ is problematic and already ambiguous in terms of what is currently implemented:\r\n\r\n * In the context of `*-Csv*` cmdlets, `-Delimiter` refers to a _separator_ - something placed _between_ elements (fields), but _not after the last_.\r\n\r\n * In the context of `Get-Content`, `-Delimiter` refers to an (optional) _terminator_, something (expected to be placed _after every element_ (record), _including the last_. \r\n`Get-Content -Delimiter` treats input that differs only with respect to a trailing delimiter identically - to signal an empty trailing element _two_ trailing delimiters are needed.\r\n\r\n * This `Get-Content -Delimiter` behavior implies that `Set-Content`, `Out-File`, ... should also treat `-Delimiter` to mean _terminator_, and add a trailing delimiter instance to the last record.\r\n\r\nDesired behavior\r\n-----------------\r\n\r\n```powershell\r\n'one', 'two' | Set-Content t.txt -Delimiter '@'\r\nget-content t.txt\r\n'---'\r\nget-content t.txt -Delimiter '@' | % { \"[$_]\" }\r\n```\r\n\r\n```powershell\r\none@two@\r\n---\r\n[one]\r\n[two]\r\n```\r\n\r\nEnvironment Data\r\n------------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-beta (v6.0.0-beta.1)\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-05-24T19:10:10Z","url":"https://github.com/PowerShell/PowerShell/issues/3855"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eaedd9c2-853c-cd82-fd9f-ee4623f45ac3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD0A:12AA8F:ACD026:F8624C:6AFDA38D |
| html-safe-nonce | ff81596c8914df8c95581742c8ec57a36a7904dda1cdddc975d620079c75c842 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDBBOjEyQUE4RjpBQ0QwMjY6Rjg2MjRDOjZBRkRBMzhEIiwidmlzaXRvcl9pZCI6IjQzNTQwMTI3NjQ0MjM2OTMxOTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a2f42f5c2bfc3570b2122444c6f160633943d88d4451324d41d41070c76ebe79 |
| hovercard-subject-tag | issue:231141759 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/3855/issue_layout |
| twitter:image | https://opengraph.githubassets.com/08181b2d8aae06ebe6ded75e2ed5d7db62f3dc828ae21217599b0bcb839d3ceb/PowerShell/PowerShell/issues/3855 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/08181b2d8aae06ebe6ded75e2ed5d7db62f3dc828ae21217599b0bcb839d3ceb/PowerShell/PowerShell/issues/3855 |
| og:image:alt | Get-Content -Delimiter can be used to read text records with an arbitrary (literally matching) terminator into an array of strings, as an alternative to reading line by line. To complement this fun... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0ddf53eb35c87f1f8df13dbf75c3bdadbfc6e969 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width