Solved

keep newline when output

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Set OWA language and time zone in Exchange for individuals, all users or per database.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now