简体   繁体   English

将文本文件的当前行打印到文本文件的前一行

[英]Print current line of text file to previous line of text file

I have a text file that I'm trying to process. 我有一个要处理的文本文件。 The data is in the form of: 数据的形式为:

1002001             1             1             1             1                1
+                   1        1.0e-4       1.24012        1.0e-4          0.44
+              1.0e-4          0.44           1.0           0.0           1.0
+                 0.0           1.0           0.0           0.0           0.0
+                 0.0           0.0           0.0           0.0           0.0

I would like to take all the lines that start with + and move them to the line that starts with '1002001', like this (kind of like sed -r ':a;N;s/\\n^\\+//g;ba ): 我想将所有以+开头的行移到以'1002001'开头的行,就像这样(有点像sed -r ':a;N;s/\\n^\\+//g;ba ):

1002001 1 1 1 1 1 1 1.0e-4 1.24012 1.0e-4 0.44 1.0e-4 0.44 1.0 0.0 1.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

这样的事情怎么样:

(Get-Content yourfile.txt -Raw) -replace '[\r\n]+\+', ''

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

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