Computing.Net > Forums > Programming > remove string values from text file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

remove string values from text file

Reply to Message Icon

Name: theblack.fox
Date: September 18, 2007 at 15:21:19 Pacific
OS: Windows XP
CPU/Ram: 512MB
Product: Dell
Comment:

I need a batch script that will remove a set of ip address out of a txt file. these ip address need to be defined in another text file or in the script

is this possible?
im a complete noob, so i need some help
thanks



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: September 18, 2007 at 15:56:34 Pacific
Reply:

You mean like this:

type file.txt > newfile.txt

You query is not clear. Please provide some additional information so we can better understand your problem.

The above simply types the contents of file.txt and redirects the output from STDOUT to newfile.txt.

"Computer security." — Oxymoron


0

Response Number 2
Name: theblack.fox
Date: September 19, 2007 at 02:16:52 Pacific
Reply:

ok say i have two files

computerlist.txt and
exclusionlist.txt

i want a batch to look at the exclusionlist.txt and remove all the values inside from the computerlist.txt


0

Response Number 3
Name: ghostdog
Date: September 19, 2007 at 02:20:25 Pacific
Reply:

here's a vbscript to find IP address and output to file.
[code]
Dim objRe,objFSO
Dim myFile
myFile = "c:\test.txt"
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objRe = New RegExp
objRe.Pattern = "\b(?:\d{1,3}\.){3}\d{1,3}\b"
objRe.Global = True
strLines = objFSO.OpenTextFile(myFile,1).ReadAll
Set Matches = objRe.Execute(strLines)
For Each match In Matches
WScript.Echo match
Next
[/code]
usage:
cscript myscript.vbs > outfile


0

Response Number 4
Name: theblack.fox
Date: September 20, 2007 at 01:53:17 Pacific
Reply:

anyway to do it in a batch script?


0

Response Number 5
Name: ghostdog
Date: September 20, 2007 at 02:26:27 Pacific
Reply:

sure, but i will not be the one to do it :) please wait.


0

Related Posts

See More



Response Number 6
Name: tonysathre
Date: September 23, 2007 at 23:57:07 Pacific
Reply:

::==rmdup
@echo off
if exist computerlist.txt (
rename computerlist.txt computerlist.tmp
)
findstr /v /g:exclusionlist.txt computerlist.tmp >> computerlist.txt
if exist computerlist.tmp (
del computerlist.tmp
)

"Computer security." — Oxymoron


0

Response Number 7
Name: theblack.fox
Date: September 26, 2007 at 14:37:46 Pacific
Reply:

tonysathre
you are a genius!


thankyou


0

Response Number 8
Name: tonysathre
Date: September 26, 2007 at 15:57:00 Pacific
Reply:

That little script actually took me a long time to figure out because I didn't know about the /g switch of the findstr command.

Glad I could help.

"Computer security." — Oxymoron


0

Sponsored Link
Ads by Google
Reply to Message Icon

UNIX shell script... how to remove \ from vari...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: remove string values from text file

Remove blank box from text file www.computing.net/answers/programming/remove-blank-box-from-text-file/19485.html

How to return value from batch file www.computing.net/answers/programming/how-to-return-value-from-batch-file/17016.html

searching a string in a text file www.computing.net/answers/programming/searching-a-string-in-a-text-file/17972.html