Solved

keep newline when output

Posted on 2013-11-14
5
295 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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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