Solved

keep newline when output

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

20 Experts available now in Live!

Get 1:1 Help Now