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目錄和文件






















