Solved

how to split multiple lines delimiter :

Posted on 2016-10-21
8
55 Views
Last Modified: 2016-10-21
windows os
this is only a small exmaple about how to split this:

aida.akbari789@gmail.com:176.58.104.12:aida1380.1393
baran_booran1@yahoo.com:2.184.85.16:BARAN_3490217012b
erfanmansorirad@yahoo.com:87.107.202.187:110110110110er1382
kdvm910@gmail.com:79.130.174.6:evr2010$

Open in new window


Output:

176.58.104.12:aida1380.1393
2.184.85.16:BARAN_3490217012b
87.107.202.187:110110110110er1382
79.130.174.6:evr2010$
0
Comment
Question by:john lambert
  • 4
  • 3
8 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 41854567
Try using powerShell..
("aida.akbari789@gmail.com:176.58.104.12:aida1380.1393" -split ":","2")[1]

Open in new window

Split from file..
GC C:\Test.txt | %{($_ -split ":","2")[1]}

Open in new window

0
 
LVL 12

Expert Comment

by:Dustin Saunders
ID: 41854568
You have a couple of different options (I'll use Powershell).  For each line you can use a substring:

$string = "aida.akbari789@gmail.com:176.58.104.12:aida1380.1393"

$output = $string.Substring($string.IndexOf(':')+1)

Write-Host $output

Open in new window


Or you could break it into an array:
$string = "aida.akbari789@gmail.com:176.58.104.12:aida1380.1393"

$array = $string.Split(':')

$output = $array[1] + ":" + $array[2]

Open in new window

1
 

Author Comment

by:john lambert
ID: 41854571
yes but cna u add Ouput.txt please?
thank you
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41854574
Try..
GC C:\Test.txt | %{($_ -split ":","2")[1]} | Out-File C:\output.txt

Open in new window

1
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:john lambert
ID: 41854579
in fact my list look like this:

gfhghjh:ghjtilouijgffghgy@gmail.com:71.200.43.81:wsxcderfv123
server-ZkOficial:yanuari_la_bella@hotmail.com:186.88.91.191:uewyK4Tk2MARkwb2
JesusEnrique:jesus_enriquest@hotmail.com:189.132.59.13:DxXp8kTUyMA1fsCZ
LUISA:luisita_crazul@hotmail.com:187.242.244.123:PUMITAS20

Open in new window


Output.txt
IP:pass
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41854587
Try following and see if it works for you..
GC C:\Test.txt | %{($_ -split ".com:","2")[1]} | Out-File C:\output.txt

Open in new window

1
 

Author Closing Comment

by:john lambert
ID: 41854593
thank you.......
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41854595
Other option is..
GC C:\Test.txt | %{($_ -split ":",3)[2]} | Out-File C:\output.txt

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

746 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

11 Experts available now in Live!

Get 1:1 Help Now