回答
文件名和行號:
system("find verilog -type f -exec grep -Hn pattern {} +")
文件名和每個文件數:
system("find verilog -type f -exec grep -Hc pattern {} +")
我想要它在perl腳本中 – user1802617
#!usr/bin/perl -w my @FILES; #my $ string =「clk」; opendir(DIR,「/ home/prodigydell3/verilog」)||死「不能打開目錄:$!」; @FILES = readdir DIR; closedir(DIR);打開(FH,「/ home/prodigydell3/verilog /」)或者死掉「$!」;打開我的$文件(@FILES){ while(
我已經有了像這樣的perl腳本,在這裏我需要在目錄中的每個文件中打印行號,文件名以及我正在搜索的模式的計數。現在我只能在Verilog文件夾中打印,但Verilog中還有其他兩個不打印的文件。請幫助我。 – user1802617
下面的命令從 「Verilog的」 目錄內給出: 使用grep -R :
對於文件名和行號:
grep -RHn pattern * | cut -d: -f-2
文件名和文件數:
grep -RHc india * | awk -F":" '$2!=0'
#!usr/bin/perl -w my @FILES; #my $ string =「clk」; opendir(DIR,「/ home/prodigydell3/verilog」)||死「不能打開目錄:$!」; @FILES = readdir DIR; closedir(DIR);打開(FH,「/ home/prodigydell3/verilog /」)或者死掉「$!」;打開我的$文件(@FILES){ while(
你能幫助我在此在代碼修改 – user1802617
我一直在grepping爲‘-R’很長一段時間... – slayedbylucifer
#!usr/bin/perl
use strict;
use File::Find;
use File::Slurp;
my $In_dir='some_path';
my @all_files;
my $pattern='test>testing string(\n|\t|\s)</test'
File::Find:find(
sub{
push @all_files,$File::Find:name if(-f $File::Find:name);
},$In_dir);
foreach my $file_(@all_files){
my @file_con=read_file($file_);
my $lne_cnt;
foreach my $con(@file_con){
my $match_="true" if($con=~m/$pattern/igs);
$lne_cnt++;
}
my $tot_line_in_file=$lne_cnt;
}
無法找到文件/找到。 pm @inC(@INC包含:/ etc/perl /usr/local/lib/perl/5.12.4 /usr/local/share/perl/5.12.4/usr/lib/perl5/usr/share/perl5/usr/lib/perl/5.12 /usr/share/perl/5.12/usr/local/lib/site_perl。)在sample2.pl第3行。 BEGIN失敗 - 編譯在sample2.pl第3行中止。 – user1802617
以前我得到mac_top.v在第45行有輸出。但現在什麼也沒有!!!!!!! – user1802617
- 1. 從目錄中逐一讀取文件
- 2. 從目錄中逐一讀取文件
- 3. 如何從目錄逐行打開和讀取文件?
- 4. 從目錄中逐行讀取多個文本文件JAVA
- 5. 如何使用Perl從目錄中的所有文件中提取模式?
- 6. Perl逐行讀取
- 7. 如何在讀取大文件(Perl)後使用SCALAR逐行讀取?
- 8. Perl:讀取目錄,直到有文件
- 9. 如何從目錄c#中讀取所有文件?
- 10. 使用perl腳本從目錄中讀取文件
- 11. 如何使用Perl列出目錄中的所有文件?
- 12. 如何從目錄中讀取文件
- 13. 如何從txt文件中逐字符讀取字符並逐行讀取C++
- 14. 從所選目錄中讀取所有文件MVC c#
- 15. 從文件中逐行讀取
- 16. 從C文件中逐行讀取
- 17. 從java文件中逐行讀取
- 18. 從一個文件中逐行讀取
- 19. 從文件中逐行讀取整數
- 20. 如何使用ant腳本從文件逐行讀取數據?
- 21. 如何逐行讀取文本文件?
- 22. 如何逐行讀取文本文件?
- 23. 如何逐行讀取一個僅限CR的文件與Perl?
- 24. 從目錄中讀取所有文件(具有不同的cwd)
- 25. 如何在perl中逐句讀取文本文件?
- 26. 如何使用Linux逐行讀取文件並將所有空格替換爲','?
- 27. 如何打開目錄並使用perl讀取該目錄內的文件
- 28. 從文件行逐行讀取
- 29. 從文本文件逐行讀取C++
- 30. android - 從文本文件逐行讀取
文件名,行號和計數...所以你要每行計數? 打印行號和每個文件的計數沒有多大意義。 – ikegami
爲什麼不使用awk(http://en.wikipedia.org/wiki/AWK)來執行此任務? – akhilless
不,我想這樣做,我想在perl做 – user1802617