Multiple find and replace of content using Grep多查找和替换的内容用Grep
Posted on December 3, 2008 at 5:35 am发布12月3日在2008年上午5时35分
We have posted articles about searching for files and file content using我们已经张贴文章搜索文件和文件内容的使用 Super Finder超级搜索 and和 Google Desktop谷歌桌面 . But what if you have a bunch of files wherein you want to actually replace a content inside them? 。但是,如果你有一大堆的文件,其中要真正取代里面的内容呢? sure you can use Notepad or any text editor to find and replace content for individual files but this will require you to do this on each of the files.确认您可以使用记事本或任何文字编辑器来查找和替换内容的个人档案但这将需要你这样做的每个文件。
I have been using Integrated Development Environment (IDEs) tools like Netbeans and Visual Studio to do this for my software development projects but they are too “bloated” for plain text files.我一直在使用集成开发环境(集成开发环境)工具,如NetBeans的和Visual Studio这样做我的软件开发项目,但他们过于“臃肿”的纯文本文件。
With带有 winGrep winGrep , you can do a global search and replace of any string on all files located at your inputted path: ,你可以做一个全球性的搜索和替换的任何字符串的所有文件位于您输入路径:
Step 1 : In the “Search in” field, enter the directory path. 第1步:在“搜索”字段中,输入目录路径。
Step 2 : In the “Search for” field, enter the string or regular expression 第2步:在“搜索”字段中,输入字符串或正则表达式
Step 3 : Click “Search” button 第3步:点击“搜索”按钮
You should see the search results on the bottom part of the screen:您应该看到的搜索结果底部的一部分,屏幕:
The listing has a column with filename, size, matches inside the file, path and encoding type. The “matches” column tells you how many instances of the searched word exists in the file.上市已经一栏的文件名,大小,比赛里面的文件,路径和编码类型。的“比赛”一栏告诉您如何许多情况下的搜索词中存在的文件。
To do a search and replace, enter the replacement word in the “Replace with:” field then click “Replace”:做搜索和替换,输入单词替换在“替换为: ”字段,然后点击“替换” :
Be careful as this can ruin your files. I usually backup my files before doing a search and replace since a replace will effectively change the content of the files. 要小心,因为这可以毁掉您的档案。我通常备份我的文件之前,做了搜索和替换,因为取代将有效地改变内容的文件。
To create backup files, make sure to check the “Create backup files” checkbox:要创建备份文件,请务必选中“创建备份文件”复选框:
The backup files will be saved on the same folder with a “.bak” extension. This way you can “recover” files by renaming the “.bak” files.备份文件将保存在同一文件夹中的。 “博”扩展。这种方式可以“收回”的文件重新命名。 “博”的文件。
If there are cases wherein you only want to make it search based on a filename pattern or file size, use the “Limit Search” options:如果有案件,其中你只希望把它变成搜索的基础上档模式或档案大小,使用“极限搜索”选项:
In the example above, I set it to search only for files with a .epj extension. You can change this to any file name extension like .log or .txt.在上面的例子中,我将其设置为只搜寻副档名为。 epj延长。你可以改变这一点的任何文件扩展名等 。 日志或。文本。
winGrep, is a powerful tool. Use it with caution because there is no “undo” functionality. Make sure to backup your critical files first before doing a replace. You can get grepWin for free from the Google code website: winGrep ,是一个有力的工具。使用它持谨慎态度,因为没有“复原”功能。请务必备份您的重要文件先做了更换。您可以免费grepWin从谷歌代码的网站:
http://code.google.com/p/grepwin/downloads/list
Ben Carigtan shows you how it’s done.本Carigtan告诉您如何它的工作要做。
» Filed Under »文章属于 Computer Tips计算机提示
Save this page 保存该网页 | Stir it up on Mixx 它搅动了Mixx | |
Add to Reddit 添加到Reddit |
Related Posts 有关职位
- Hide extensions for known file types in Windows Vista隐藏已知文件类型的扩展在Windows Vista
- Combine or merge multiple text files using TXTCollector联合或合并多个文本文件使用TXTCollector
- Combine multiple commands and executables into a single exe联合收割机多个命令和可执行文件成一个单一的EXE
- Find and remove duplicate files with Duplicate Cleaner查找和删除重复的文件重复清洁
- Create HTML table listing of Windows directories and files创建HTML表列出的Windows目录和文件






















