-5
1111    700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1
2211    700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1
3311    700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1
        700000000000c940  FIBRE  FA-11G:1,FA-12G:1

如何使用 powershell 在同一行打印?

1111 700000000000c940 700000000000c940 700000000000c940 700000000000c940.
2211 700000000000c940 700000000000c940 700000000000c940 700000000000c940.
3311 700000000000c940 700000000000c940 700000000000c940 700000000000c940.

任何帮助将不胜感激

4

2 回答 2

0

如果你有 PowerShell v3,试试这个单行:

(Get-Content file.txt -Raw) -replace '(?<=\w{16}\s).+' -replace '(?<= ) |\r?\n\s+'
于 2013-07-09T15:30:06.333 回答
0

现在它变得更有意义了。看看我最喜欢的文本解析工具switch -regex

switch -regex -file foo.txt {
    '^(\d+)\s+(\S+)' {
        if ($s) { $s }
        $s = "$($Matches[1]) $($Matches[2])"
    }
    '^\s+(\S+)' { $s += " $($Matches[1])" }
}
if ($s) { $s }
于 2013-07-09T08:51:13.340 回答