Solved

Find and Replace Text in a Text File for multiple stings??

Posted on 2006-11-09
3
158 Views
Last Modified: 2010-04-16
Maybe I'm at a block here, but I need to have a script replace multiple stings in a file, or better yet, delete those stings and format a text file.  What I need is to display the path right after C:\ then delete everything but the User\Specific sting....  that said, a target seach would work from this, but I don't know how to run multiple queries..

http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0208.mspx



C:\IO.SYS BUILTIN\Administrators:F
          BUILTIN\Administrators:F
          NT AUTHORITY\SYSTEM:F
          BUILTIN\Users:F
          User\Specific

C:\Logon.log BUILTIN\Administrators:F
             NT AUTHORITY\SYSTEM:F
             BUILTIN\Users:F
             User\Specific

0
Comment
Question by:rtmcmullen
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 17911051
Can you show us what the modified file should look like when we are done?...
0
 

Author Comment

by:rtmcmullen
ID: 17912426
I want to take out everything but the file after the C:\ and "User\Specific" stings.

So for example, on the above, it would be:

IO.SYS
User\Specific

and

Logon.log
User\Specific
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 17914569
Ok.

Speaking generically now...

Could there more more than two "blocks"?
If yes, do we only do the first two or the whole file?

Is there always a space inbetween the blocks?

Will we always keep the file from the first line of the block and only the last line of the block?
(The first block has 5 lines while the second has 4.)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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