简体   繁体   中英

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 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]+\+', ''

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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