D
D
DeadFine2011-01-29 19:47:56
Content
DeadFine, 2011-01-29 19:47:56

Filtering lines in a text file?

There is a text file with lines like IP:Port
How to filter it, leaving only lines starting with 10.* and 172.*?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
N
Nikita, 2011-01-29
@DeadFine

Write to icq: 559343705 - I will write for you for thanks

V
Vas3K, 2011-01-29
@Vas3K

grep "^10." ip.txt?

D
Dunadan, 2011-01-29
@Dunadan

If you are using Windows and the file is not very large, export it to Excel and sort and filter there.

A
agul, 2011-01-29
@agul

Use regular expressions if you are familiar with them.
If you are interested in software implementation, then everything depends on the chosen programming language.

S
Stalker_RED, 2011-01-29
@Stalker_RED

grep (or findstr on Windows)

P
Petrify, 2011-01-29
@Petrify

I advise you to use perl, although in any language like C ++ it will be a program in several lines

P
Puma Thailand, 2011-01-29
@opium

cat + grep?

S
SkyKos, 2011-01-30
@SkyKos

If you use powershell (it comes with new Windows starting with Vista, it is installed additionally on XP), then you can do this:
> cat .\file.txt | Select-String "172." > c:\output.txt
> cat .\file.txt | Select-String "10." >> c:\output.txt
Note that the second line uses a double ">" to indicate appending to the end of the file. A single character replaces the content, a double character appends to the end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question