topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 4:02 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Simple free commandline text search and replace tool?  (Read 31010 times)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Simple free commandline text search and replace tool?
« on: November 28, 2008, 10:25 AM »
I'm looking for a really simple commandline search and replace tool, which can be run non-interactively and told to find and replace a string in a text file.
Any suggestions?

Veign

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 993
    • View Profile
    • Veign - Where design meets development
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #1 on: November 28, 2008, 10:31 AM »
My Seeker application has command line support.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #2 on: November 28, 2008, 10:43 AM »
Wow when did that come out Veign -- i don't remember you posting about it.  Looks cool !

Veign

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 993
    • View Profile
    • Veign - Where design meets development
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #3 on: November 28, 2008, 10:53 AM »
Been working on it for a couple years now.  Its what I use to manage websites as its dead simple for me to locate text within a large website project.

Whats kinda neat about Seeker is the four reporting methods and the native search for Word documents and Excel spreadsheets (will tell you what sheet within a workbook a text string was located).

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #4 on: November 28, 2008, 10:57 AM »
yeah the native search is pretty damn cool.

Veign

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 993
    • View Profile
    • Veign - Where design meets development
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #5 on: November 28, 2008, 11:02 AM »
There are some things I need to get working better.  If you watch the status bar you will see how fast it searches (in memory) but how slow it is at generating the report display (especially the detailed report).  Writing to any kind of display memory is slow and I need to virtualize the display where its only loading into the display memory what is actually being shown to the user and not the full report.

Also, the right click on the detailed report will only work properly if the files are in the same folder.  There is no mechanism to use the Explorer right click menu when files span different folders - at least that I know of.

Oh and the Help file is not that good - I hate writing help files...
« Last Edit: November 28, 2008, 11:06 AM by Veign »

gexecuter

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 252
  • Move over and give us some room...
    • View Profile
    • Elite Freeware
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #6 on: November 28, 2008, 06:41 PM »
Fart only has a command line interface so you should check it out. I haven't tried it yet because i am pretty bad with command line interfaces and i am afraid i might screw something up  :(
Mouser is made of win and awesome!

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #7 on: December 01, 2008, 04:16 AM »
MiniTrue, A. Pipkin's "Ministry of Truth" (MT) utility.  On NO ACCOUNT overlook Eric Pement's third-party comments on it.  Go to his SED page and page down until you get to Console/command-line apps.  Direct link to his extra document here.  You need to know about its misbehaviours and workarounds.  I use it successfully under XP, but only with short file names.

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #8 on: December 01, 2008, 04:48 AM »
rjbull: Eek, using 16bit dos executables under win32? Why haven't you searched for a replacement tool? :)
- carpe noctem

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #9 on: December 01, 2008, 07:57 AM »
rjbull: Eek, using 16bit dos executables under win32? Why haven't you searched for a replacement tool? :)

It's free, and, for my use, it works.  "My use" is mostly dealing with files made by DOS editors, and I use those because I'm familiar with them and because they're WordStar-style.  Also it's surprisingly hard to find a free Windows editor that does automatic *.BAK back-ups and has bookmarks.

I do have a Win32 search-and-replace tool now - HFFR Text WorkBench.  Just checked the Help file, and as well as GUI it has command-line support, though I've not had cause to use it yet.  Does Unicode, too.

[Edit]  Oops, just remembered this is about "free" apps.  HFFR Text WorkBench is payware.  You can still find the last free version, but I don't think it accepts command line arguments and it only does a single search-and-replace pair.  That was another of the advantages of MiniTrue, many pairs.
[/Edit]



« Last Edit: December 01, 2008, 10:24 AM by rjbull »

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #10 on: December 01, 2008, 08:27 AM »
I was just wondering :) - DOS programs have a disadvantage running under windows since they need some virtualization... and won't run at all under 64bit windows (outside of full emulation, like dosbox). I still use plenty of console applications, but it's been several years since I've used anything 16bit. Seems like the 32bit version is DJGPP, no wonder it's quirky on NT based operating systems then :)
- carpe noctem

Rover

  • Master of Smilies
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 632
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #11 on: December 01, 2008, 01:46 PM »
I have used this before and found it more than adequate.  :Thmbsup:

GSAR:  GSAR Project Page

gsar (General Search And Replace) is a utility for searching for and --- optionally --- replacing strings in both text and binary files. The search and replace strings can contain all kinds of characters (0--255), i.e. Ctrl characters and extended ASCII as well.

The algorithm used is a variation of the Boyer-Moore search algorithm, modified to search binary files. As a result of this, gsar is blindingly fast.

Opposed to line oriented search programs (like grep(1)), gsar will find all matches on a line. Actually, gsar doesn't know anything about lines at all, all files and strings are treated as binary.

Gsar can search one or several files for a string and report the occurrences. Gsar can read one file, search for a string, replace it with some other string, and create a new file containing the changes. Gsar can perform a search and replace in multiple files, overwriting the originals. Finally, gsar can work as a filter, reading from standard input and writing to standard output.
Insert Brilliant Sig line here

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #12 on: December 02, 2008, 03:36 AM »
I have used this before and found it more than adequate.  :Thmbsup:

GSAR:  GSAR Project Page

I'd forgotten that one, even though I still use the DOS version - and it's a good one, too.  But again, unless they've updated it, it will only do one search/replace pair at a time.  When I wanted multiple pairs to use as a user-defined tool in TED Notepad and in ClipboardHelp+Spell, I ended up using SED.


skas

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #13 on: December 02, 2008, 07:58 AM »
Why not use something like GNU grep? It's strictly command-line, and it can be set for silent mode too. Download and/or read documentation at: <http://www.gnu.org/software/grep/>

But if you want an app that provides an easy-to-use GUI for building & saving sets of search-replace operations -- which you can then call from a command-line -- consider BK ReplaceEm.

This 32-bit Windows freeware application hasn't been supported or distributed by its developer Bill Klein (BK) for a number of years. But it was once considered among the very best search-n-replace apps (free or not). And I think it still deserves such consideration.

For a rather complicated example of the very sort which originally inspired BK to create his application, see: <http://www.ccp14.ac.uk/ccp14admin/bkreplacem/index.html>.

But the download URL on the latter webpage is dead. To download it, you must use an archive website like SnapFiles: <http://files.snapfiles.com/localdl834/bkrep20.exe>.

It's a very safe program to install & try -- it just puts its files in a single folder w/o any changes to the registry, as I recall.

With BK ReplaceEm, you use replace groups and file sets.

A replace group consists of a series of search & replace strings (regular expressions & 'range replacements' are supported, and any series of simple boolean operations can be input & saved via the GUI too).

A file set consists of a single file, multiple files, or a whole directory  -- perhaps filtered by particular file extensions. Whatever.

You can have the program create a backup copy of every file it operates on, in case things don't go as you expected.

You can have the program output to different locations too. And if you want, you can set the application to run additional -- and different -- replacement operations on all files found in that second location. Logs can be generated too.

I hope that's an accurate description. It's a been a while since I've used it. I invested in the very expensive TextPipe Pro a couple years ago, which, I think is the application BK ReplaceEm most resembles.

BTW, anyone interested in search & replacement operations would be well-served by Friedl's book, 'Mastering Regular Expressions', now in its 3rd edition from O'Reilly. I'm not a programmer, but this book has helped me greatly in parsing & editing text, in website development & maintenance, even in finding & managing files on my desktop PC -- all via the numerous applications that now support Perl & other varieties (like grep) of regular expressions.

Steve

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #14 on: December 02, 2008, 10:32 AM »
But if you want an app that provides an easy-to-use GUI for building & saving sets of search-replace operations -- which you can then call from a command-line -- consider BK ReplaceEm.

I looked through BKReplacem's command line options a while back, and didn't really understand them   :-[  So I went with SED.  It's case-sensitive, but that was OK for what I wanted.


criss

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 17
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #15 on: December 03, 2008, 09:02 AM »
Perhaps XChangeCL: http://www.sadmansoftware.com/xchangecl/

I did not try it, but I use daily their Search Program which is great and the author is very resposive.

Sundog29

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 3
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #16 on: May 13, 2009, 11:25 AM »
http://www.gnu.org/software/grep/>

But if you want an app that provides an easy-to-use GUI for building & saving sets of search-replace operations -- which you can then call from a command-line -- consider BK ReplaceEm.

This 32-bit Windows freeware application hasn't been supported or distributed by its developer Bill Klein (BK) for a number of years. But it was once considered among the very best search-n-replace apps (free or not). And I think it still deserves such consideration.

For a rather complicated example of the very sort which originally inspired BK to create his application, see: <http://www.ccp14.ac.uk/ccp14admin/bkreplacem/index.html

BK ReplaceEM seems to have been republished by ecobyte software as Replace Text v2.2 (free).
http://www.ecobyte.com/replacetext/

Ross MacGregor

  • Participant
  • Joined in 2013
  • *
  • default avatar
  • Posts: 1
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #17 on: January 23, 2013, 02:32 PM »
I've written just such a tool for Windows. It is easy to use yet has many features that many people eventually need. It supports Unicode, can search multiple files, and is small, fast and free.

https://sites.google...simplesearchreplace/

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #18 on: January 25, 2013, 03:17 PM »
I've written just such a tool for Windows.
-Ross MacGregor (January 23, 2013, 02:32 PM)
Thanks for telling us about this.  Does the Options file allow one to enter multiple search-and-replace pairs?

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: Simple free commandline text search and replace tool?
« Reply #19 on: January 25, 2013, 05:58 PM »
It has the following features:

    Easy to use in Windows batch files
    Supports Windows and Unix line endings
    Unicode support
    Accepts multiple search/replace arguments
-SSR 2