→ play9091:open(name,"filename.txt") 04/27 14:30
→ play9091:for $line (<name>){ 04/27 14:32
→ play9091: if (line =~ m/Access Time/){ 04/27 14:33
→ play9091: @sline = split(' ',$line); 04/27 14:35
→ play9091: print "$sline[3]\n"; 04/27 14:36
→ play9091: } 04/27 14:37
→ play9091:} 04/27 14:37
→ play9091:Sorry,第一行的行末沒有加上分號 " ; " 04/27 14:38
→ play9091:第三行的 " line " 改為 " $line " 04/27 14:38
推 play9091:最近在寫 Python , Perl 反而有點生了! 04/27 14:41
→ japanet:感謝不盡~ 04/28 13:00
→ japanet:可以再請教如何讀多個檔案進來跑這個for loop呢? 04/28 13:06
推 play9091:要多加檔案的話要改寫吧!您有寫過Perl嗎? 04/28 17:31
→ play9091:外面再包一個LOOP,或是另外一種寫法…… 04/28 17:31
推 pshuang:print `cat file | grep "Access Time" |cut -d ":" -f 3` 05/03 18:08
→ pshuang:用perl來處裡shell最擅長的事,不會很累嗎? 05/03 18:09
→ pshuang:要多個檔案 把cat file 中 file 改成變數就好 05/03 18:11
推 HowLeeHi:不用多一道cat手續,直接 grep "Access Time" file省時 05/29 17:50
→ HowLeeHi:然後cut -d ":" -f 2 05/29 17:52