MSFN Forum: Replace string of file on command line - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Replace string of file on command line Rate Topic: -----

#1 User is offline   kukris 

  • Member
  • PipPip
  • Group: Members
  • Posts: 106
  • Joined: 28-November 03

Posted 01 September 2006 - 02:12 PM

Hi,

I want to replace an expression in a file with another expression on a command line.
Example

prog.exe <string1> <string2> <filename>


Does anyone know such a tool?


#2 User is offline   Bark 

  • Group: Members
  • Posts: 5
  • Joined: 16-September 03

Posted 01 September 2006 - 03:41 PM

In the UNIX world they would use a utility named "sed". Here's a port: http://gnuwin32.sour...ackages/sed.htm. It's not the easiest thing in the world to use, but it's not that hard either once you get the hang of it.

#3 User is offline   Ctrl-X 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 444
  • Joined: 29-August 06

Posted 02 September 2006 - 03:08 AM

I like GSAR better... Personally I think it's easier to use.

#4 User is offline   kukris 

  • Member
  • PipPip
  • Group: Members
  • Posts: 106
  • Joined: 28-November 03

Posted 02 September 2006 - 03:40 PM

Thanks,

Gsar looks more easy, but I couldn't get it to work with search strings with a comma, but that is what I need.
It doesn't work for a string containing a comma and text, like 0,win. I tried to put it in quotes, but no luck.
Then I replaced it with ASCII or Hex-Code it just displays one match, but there are much more.

Does anybody know a solution for that or another tool?

#5 User is offline   At0mic 

  • Enthusiast
  • PipPip
  • Group: Members
  • Posts: 288
  • Joined: 10-February 05

Posted 02 September 2006 - 04:24 PM

Yes use Munge.exe. Its part of the NT4 Resource Kit. You can search for it using google, I used it a few days ago for a batch file and it works very well.

Just create a txt file containing the current string and the required string separated by a space. You can sounded the string with " " as it works with any quoted text so your expression should work.

MUNGE strings.txt -l -t file.txt

strings.txt contains your search strings and file.txt is the file you want to edit

#6 User is offline   kukris 

  • Member
  • PipPip
  • Group: Members
  • Posts: 106
  • Joined: 28-November 03

Posted 03 September 2006 - 04:49 AM

Thanks At0mic,

that's the most easiest and Windows-like tool.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy