Solved

keep newline when output

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
powershell query 2 25
PowerShell script to find registry values for all computers in a Domain 17 80
Powershell command 2 24
Need to combine two scripts 2 12
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This article will help you understand what HashTables are and how to use them in PowerShell.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

832 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