I want split using -.

hello

I want help about split function. I want change old.txt like new.txt.
Now I try using %{"$($_.Split("      ")[3,0,1,10,12-50])"}.

old.txt data is below
=============================================================
8/30/2015 21:41:25  XXX2020     EMERGENCY         sysconf.logErr: sysconfig: Adapter blablablabla
8/31/2015 20:41:25  XXX2020     WARNING         cmds.logErr: blablablabla
8/29/2015 11:41:25  XXX2020     ERROR         logErr: sysconfig: Adapter blablablabla
=============================================================

new.txt data is below
=============================================================
XXX2020 8/30/2015 21:41:25 sysconf.logErr: sysconfig: Adapter blablablabla
XXX2020 8/31/2015 20:41:25 cmds.logErr: blablablabla
XXX2020 8/29/2015 11:41:25 logErr: sysconfig: Adapter blablablabla
=============================================================


September 1st, 2015 3:32am

You can place it all on one line by adding a ; command separator.

$( gc old.txt | %{ $a = $_ -split '\s+',5; $a[2]+' '+$a[0]+' '+$a[1]+' '+$a[4] } ) | out-string -stream | out-file new.txt

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 7:52am

can you make one line command?

Where's your effort? What have you tried? What is wrong with it?

We're not here to do your work for you.

September 1st, 2015 7:54am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics