# I need a text-replace program that can do this:

**URL:** <https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332>\
**Category:** Factual Questions\
**Created:** [April 27, 2005, 7:09am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332 "2005-04-27T07:09:43Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![CynicalGabe](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@CynicalGabe](https://boards.straightdope.com/u/CynicalGabe)\
**Post date:** [April 27, 2005, 7:09am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/1 "2005-04-27T07:09:43Z")

</div>

I need a shareware or free ware text search/replace application that can insert text at the end of the document in addition to the normal features such a program has.

Example:

Find Documents containing text: \<html\>  
Insert at end: \</html\>

Any suggestions? Thanks.

---

<div class="post-metadata">

**Author:** ![spotmaker](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@spotmaker](https://boards.straightdope.com/u/spotmaker)\
**Post date:** [April 27, 2005, 10:30am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/2 "2005-04-27T10:30:44Z")

</div>

I take it you’re using Windows? I can’t recommend any point-and-click program for this, but if it’s important enough to be worth some trouble – especially if you’re going to need to do this sort of thing again – you may want to [get perl](http://www.perl.org/get.html) and learn how to use it.

---

<div class="post-metadata">

**Author:** ![Ponster](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ponster/32/17081_2.png) [@Ponster](https://boards.straightdope.com/u/Ponster)\
**Post date:** [April 27, 2005, 10:34am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/3 "2005-04-27T10:34:57Z")

</div>

You could try getting Ultraedit (shareware) and creating a quick macro (very easy). You just open a file, search for the string, go to the end of the line and then insert manually the \</html\> and then save the macro.

You can then let it run it self through the file until it’s done.

---

<div class="post-metadata">

**Author:** ![primer\_dimer](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@primer\_dimer](https://boards.straightdope.com/u/primer_dimer)\
**Post date:** [April 27, 2005, 1:19pm UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/4 "2005-04-27T13:19:37Z")

</div>

If you have access to a Linux box, something like should work (deep breath):

```auto

grep -l '<html>' * | xargs -ti bash -c "echo '</html>' >>{}" 

```

If you can put the files up on the web somewhere I could run it on my box, if the dataset’s not too big.

Good luck

---

<div class="post-metadata">

**Author:** ![scr4](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@scr4](https://boards.straightdope.com/u/scr4)\
**Post date:** [April 27, 2005, 2:01pm UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/5 "2005-04-27T14:01:45Z")

</div>

> [@primer\_dimer](#):
>
> If you have access to a Linux box…

And if not, you can use [cygwin](http://www.cygwin.com/).

---

<div class="post-metadata">

**Author:** ![UncleRojelio](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/unclerojelio/32/3160_2.png) [@UncleRojelio](https://boards.straightdope.com/u/UncleRojelio)\
**Post date:** [April 27, 2005, 2:05pm UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/6 "2005-04-27T14:05:04Z")

</div>

On a Mac, the grep incantation would work, you could use ‘sed’, or if you want a GUI application, use [BBEdit](http://www.barebones.com/products/bbedit/index.shtml).

---

<div class="post-metadata">

**Author:** ![erislover](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@erislover](https://boards.straightdope.com/u/erislover)\
**Post date:** [April 27, 2005, 2:16pm UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/7 "2005-04-27T14:16:53Z")

</div>

This as good of a place as any to ask, if I hope to start learning Linux, would cygwin be a good place to start rather than a clean install on an old computer?

---

<div class="post-metadata">

**Author:** ![scr4](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@scr4](https://boards.straightdope.com/u/scr4)\
**Post date:** [April 27, 2005, 5:01pm UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/8 "2005-04-27T17:01:02Z")

</div>

> [@erislover](#):
>
> This as good of a place as any to ask, if I hope to start learning Linux, would cygwin be a good place to start rather than a clean install on an old computer?

Cygwin is a unix-like environment that runs on top of Windows. It’s like having a user account (not root/administrator access) on your company/school’s unix system. I think it’s a good way to learn to _use_ a unix system, including programming, but it won’t teach you much about administering a unix system.

I like having cygwin on my PC - it lets me use simple unix tools like grep and run simple shell scripts. It’s useful in cases exactly like this OP’s. It also works as an X-windows server to run graphical programs remotely - i.e. you log on to another machine and have it open a window on your screen.

---

<div class="post-metadata">

**Author:** ![Gary\_Robson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/gary_robson/32/3448_2.png) [@Gary\_Robson](https://boards.straightdope.com/u/Gary_Robson)\
**Post date:** [April 27, 2005, 10:29pm UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/9 "2005-04-27T22:29:02Z")

</div>

Grep is the world’s most wonderful command line program, and you can use it on just about any operating system there is. It is built into Linux, Unix, Solaris, FreeBSD, and so forth. Mac OS X has it in the underlying BSD. You can download it for Windows and DOS.

If Grep can’t do everything you want, then get perl. When you do, hie thee to O’Reilly and get the camel book and llama book. I’ve written perl programs on a Linux box, debugged them on a Windows box, and then deployed them on a Sun box. It just works.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [April 28, 2005, 12:38am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/10 "2005-04-28T00:38:24Z")

</div>

Hey, where’s the love for awk? That’s my command-line programmable filter of choice. I really need to get in more practice with it, though…

---

<div class="post-metadata">

**Author:** ![CynicalGabe](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@CynicalGabe](https://boards.straightdope.com/u/CynicalGabe)\
**Post date:** [April 28, 2005, 1:20am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/11 "2005-04-28T01:20:34Z")

</div>

Thanks for the suggestions, but I’m kind of a klutz at learning code (as anyone who goes to my website can tell), so I was hoping for more of a shareware app of the type you find on [download.com](http://download.com) or [versiontracker.com](http://versiontracker.com).

No fuss, no muss, and no rough stuff.

---

<div class="post-metadata">

**Author:** ![Ponster](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ponster/32/17081_2.png) [@Ponster](https://boards.straightdope.com/u/Ponster)\
**Post date:** [April 28, 2005, 9:07am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/12 "2005-04-28T09:07:18Z")

</div>

> [@CynicalGabe](#):
>
> Thanks for the suggestions, but I’m kind of a klutz at learning code (as anyone who goes to my website can tell), so I was hoping for more of a shareware app of the type you find on [download.com](http://download.com) or [versiontracker.com](http://versiontracker.com).
> 
> No fuss, no muss, and no rough stuff.

Err, what about my reply?

Shareware, 30-day limit, 1.7Mb…

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [April 28, 2005, 11:38am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/13 "2005-04-28T11:38:36Z")

</div>

> [@CynicalGabe](#):
>
> Thanks for the suggestions, but I’m kind of a klutz at learning code (as anyone who goes to my website can tell), so I was hoping for more of a shareware app of the type you find on [download.com](http://download.com) or [versiontracker.com](http://versiontracker.com).
> 
> No fuss, no muss, and no rough stuff.

And you never thought that none of those tools might be right for the job?

Frankly, it’s easier to learn something a bit complex than to pore through thousands of web pages and struggle with a tool that _almost_ does what you want but is so simplistic you can’t make it solve the problem. There are very good Perl tutorials online and in book form, and taking some time now to work through one of them will make you capable of solving problems much faster in the future. What’s more, you won’t have to juggle a dozen ‘almost’-solutions or try to find a pre-written program that does something just a little bit closer to what you really need.

I’m sorry for the rant, but I wouldn’t be wasting my time if I didn’t think you could get something out of it.

Some free online resources:  
[ul]  
[li][http://www.perlmonks.org/index.pl?node\_id=418141](http://www.perlmonks.org/index.pl?node_id=418141) – This assumes no prior programming experience. (HTML doesn’t really count, but JavaScript does.)[/li][li]Me, for one. Ask a question about Perl in GQ and it _will_ get answered. This isn’t the best way to do it, but hopefully I or someone else will get you on the right track.[/li][/ul]

(Learning grep will probably be a lot harder, because the documentation isn’t aimed at someone like you. Once you know Perl, grep and awk will be a cinch, however.)

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [April 28, 2005, 11:43am UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/14 "2005-04-28T11:43:36Z")

</div>

Oh, and two more references:  
[http://www.sthomas.net/oldpages/roberts-perl-tutorial.htm](http://www.sthomas.net/oldpages/roberts-perl-tutorial.htm)  
[http://www.perlmonks.org/index.pl?node=Tutorials](http://www.perlmonks.org/index.pl?node=Tutorials)

You can Google for ‘perl tutorial’ or ‘perl introduction’ if you want.

---

<div class="post-metadata">

**Author:** ![CynicalGabe](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@CynicalGabe](https://boards.straightdope.com/u/CynicalGabe)\
**Post date:** [April 28, 2005, 2:26pm UTC](https://boards.straightdope.com/t/i-need-a-text-replace-program-that-can-do-this/301332/15 "2005-04-28T14:26:29Z")

</div>

> [@Ponster](#):
>
> Err, what about my reply?
> 
> Shareware, 30-day limit, 1.7Mb…

Sorry, I missed yours. Looking for the app now. Thanks.
