Find and replace from a command line

General questions about using WildEdit

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
dbrs4me
Posts: 1
Joined: Tue Oct 13, 2009 7:18 pm

Find and replace from a command line

Post by dbrs4me »

I am trying to run a find and replace from a command line. I want to look in 3 different directories. I am looking for an ellipsis, … and I want to replace it with a tilde, ~ .

I would rather not save the original file. I just want to check the directory, if there is a file with ellipses in it I want to change them all to tildes and just save the file.

I hope this is easy.

Thanks in advance. Charlie
User avatar
klepton
Posts: 5
Joined: Fri Feb 11, 2005 1:25 am
Location: San Francisco, CA

Post by klepton »

I wasn't aware that one could use WildEdit to do search & replace from command line. Its help file under Reference, Command Line only lets you specify folder, file, and config file... maybe some way to figure out the XML that the config file uses, but it's not obvious. WildEdit provides a nice GUI interface for various search & replace types on multiple files, not really aimed at command line.

The things I can think of are some scripting tool to feed keystrokes, etc. to WildEdit (probably more trouble than it's worth), one of the many simpler command line search & replace tools available on software sites (which I haven't used since the DOS days), or else a more general tool like sed or Perl (for Windows from http://activestate.com). I generally switch between WildEdit and Perl. sed and especially Perl have steep learning curves, but for simple search and replace you could get away with just a little.

E.g. get sed (Stream EDitor) from http://gnuwin32.sourceforge.net/packages.html, and install. Command to substitute ("s///" command) ellipsis (ANSI hex 85) with tilde (hex 7E) is:
sed -i.bak -e "s/\x85/\x7E/g" filename.txt
The -i.bak leaves original file in filename.txt.bak. Without that, you have to direct output to a separate file, e.g. append: > changed_filename.txt

This sed version leaves some leftover temporary files "(sedXXXXX").
This sed version has some support for wildcards in file names.

Good luck!
- Scott B.
Post Reply