简体   繁体   English

指定线长Powershell

[英]Specify line length powershell

I need to specify the line lenght with powershell. 我需要用powershell指定行长度。 I have a source file with lines with different line lenghts and i need to export them to a new file with all the same line lengths, 470. I found a command but this will add some with spaces in front of the line and i need to add the spaces at the end of the line. 我有一个带有不同行长度行的源文件,我需要将它们导出到所有相同行长470的新文件中。我找到了一个命令,但这会在行前添加一些空格,我需要在行尾添加空格。

$sourcefile = '.\file.txt'
foreach ($row in $sourcefile) {
$row = [string]::Format("{0,469}",$row) | out-file '.\newfile.txt' -append }

Use a negative number to specify left alignment in a given space. 使用负数指定给定空间中的左对齐。

Eg. 例如。

'#{0,-10}#' -f 43

outputs: 输出:

#43        #

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM