轉:一個在文字檔案搜尋指定字串的程式
用perl實現的.
[@more@]
print "input file:";
$file=
chomp($file);
open (Hand,$file)||die "can not open file";
print "input the string to search:";
$str=
chomp($str);
print "the result:n";
$i=0;
while (
{
$i++;
while (/$str/g)
{
print "line".$i.": ".$_;
}
}
儲存為search.pl
C:>perl search.pl
input file:hello.txt
input the string to search: hello
the result:
line2: this is a hello test.
lien5: helloworld.
這個程式執行特別快.
本文來自CSDN部落格,轉載請標明出處:http://blog.csdn.net/treeroot/archive/2004/10/09/129199.aspx
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/220284/viewspace-1024365/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 搜尋檔案下包含某個字串的檔案字串
- 通過API開啟PDF檔案,並進行指定文字的搜尋API
- HHDESK檔案內文字搜尋功能
- 在windows裡面用命令搜尋哪個檔案裡包含了所需要查詢的字串Windows字串
- 智慧小程式檔案館——搜尋流量接入(一)
- 電腦如何利用Bat刪除文字檔案指定字串?BAT字串
- 使用grep搜尋多個字串字串
- 字串搜尋字串
- 檔案智慧搜尋
- win10搜尋檔案在哪裡 檢視搜尋檔案位置的方法Win10
- java檔案受限搜尋Java
- 【問題】 檔案搜尋
- Google照片現在可以搜尋照片中的文字Go
- 一個高效搜尋github專案的網站Github網站
- Nebula 基於 ElasticSearch 的全文搜尋引擎的文字搜尋Elasticsearch
- Vim模糊檔案搜尋fzf
- 檔案搜尋工具ProFind for MacMac
- ProFind for Mac(檔案搜尋工具)Mac
- Mac pdf檔案搜尋工具Mac
- Linux 檔案搜尋命令Linux
- 常見檔案搜尋命令
- 檔案許可權管理命令chmod,chown與文字搜尋命令grep
- git merge一個指定檔案Git
- 精通 Linux 上的檔案搜尋Linux
- 校驗檔案的搜尋規則
- 搜尋檔案中的關鍵字
- Eclipse + Jboss + Lomboz的檔案搜尋Eclipse
- linux 搜尋檔案及所有子目錄下的檔案裡的內容 (轉)Linux
- Windows XP 增加可執行檔案的搜尋路徑(轉)Windows
- 替換文字檔案中指定的內容
- 在ZOHO企業網盤中如何快速搜尋檔案?
- 刪除檔案中包含指定字串的行字串
- 一個簡單的檔案管理程式 (轉)
- PDF Search for Macpdf檔案搜尋工具Mac
- Find Any File for Mac(檔案搜尋)Mac
- Scherlokk for Mac檔案搜尋軟體Mac
- Scherlokk for Mac(檔案搜尋軟體)Mac
- 檔案搜尋軟體:Scherlokk MacMac