Solved

keep newline when output

Posted on 2013-11-14
5
292 Views
Last Modified: 2013-11-15
I have a file 'abc'  of the following format

select [var1]
          ,[Var2]
          ,[Var3]
from table1

I try to read it in using
(gc abc)

do some string manipuiation, But when I output I get a stream of character with no newline.
How can I keep the newline or insert newline. So my output will be like
select [xvar1]
          ,[xVar2]
          ,[xVar3]
from table1
0
Comment
Question by:tommym121
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39649212
How you are manipulating string?

You can try.
GC abc.txt | % {$_ -replace "\[","[X"} | Set-Content cdf.txt

Open in new window

0
 

Author Comment

by:tommym121
ID: 39650145
Subsun,
What I try to do is to transform a stream of token into a new line before each token.
0
 

Author Comment

by:tommym121
ID: 39650153
Just to be clear

from

select [var1] ,[Var2] ,[Var3] from table1

into

select [var1]
          ,[Var2]
          ,[Var3]
from table1
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39651099
Does this work?
$Srting = "select [var1] ,[Var2] ,[Var3] from table1"
$Srting -replace "\] ","]`n"

Open in new window

0
 

Author Closing Comment

by:tommym121
ID: 39651199
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Synchronize a new Active Directory domain with an existing Office 365 tenant
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question