gpt4 book ai didi

windows - 使用 Powershell 的 UNIX 格式文件

转载 作者:可可西里 更新时间:2023-11-01 13:00:06 32 4
gpt4 key购买 nike

如何在 Powershell 中创建 unix 文件格式?我正在使用以下内容创建文件,但它始终以 Windows 格式创建文件。

"hello world" | out-file -filepath test.txt -append

据我了解,新行字符 CRLF 使其成为 Windows 格式文件,而 unix 格式只需要在行尾有一个 LF。我尝试用以下内容替换 CRLF,但没有用

"hello world" | %{ $_.Replace("`r`n","`n") } | out-file -filepath test.txt -append

最佳答案

PowerShell Community Extensions 中有一个 Cmdlet称为 ConvertTo-UnixLineEnding

关于windows - 使用 Powershell 的 UNIX 格式文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5102115/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com