Re: [問題] awk 一特殊用法

看板Linux作者 (dryman)時間13年前 (2013/02/22 04:30), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串3/3 (看更多)
#!/usr/bin/env perl # It reads from STDIN while ($string=<STDIN>) { # push $string to @lines until reach numbers push @lines, $string and next unless $string =~ /^\d+/; # print @lines if last element is 'ccc' print @lines if $lines[$#lines] =~ /ccc/; # reset @lines with first element as numbers @lines = ($string); } # handle end of file print @lines if $lines[$#lines] =~ /ccc/; Perl 處理文字真的超強,不考慮學一下嗎?XD -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 68.181.7.7

02/22 08:57, , 1F
Perl 推一個XDDDDDDDDD
02/22 08:57, 1F

02/22 19:44, , 2F
perl -ne 'BEGIN{undef $/};
02/22 19:44, 2F

02/22 19:45, , 3F
print "$1\n" while /(\d+\/\d+[^\d]*ccc)/sg' 檔案
02/22 19:45, 3F

02/23 00:31, , 4F
Perl 處理這類問題真的看來超強。
02/23 00:31, 4F
文章代碼(AID): #1H9eFNpt (Linux)
文章代碼(AID): #1H9eFNpt (Linux)