Skip to main content


Showing posts from February, 2013

Concatenate lines in a file into a single line with PowerShell

Assuming you have a input file in.txt with following lines:a b cand you'd like to concatenate these 3 lines into a single line to a file out.txt i.e.abcYou can use the following PowerShell command:-join (cat in.txt) | out-file out.txtBasically, the cat in.txt is executed first and returned the content of in.txt as an array of strings. The -join cmdlet then joins the lines together into a single line, which is then piped (|) into the out-file cmdlet to produce the out.txt file.