RE!

列出檔名為A,B,C,D開頭,並計數

ls |egrep "^[ABCD]" |wc

[ABCD] 為A或 B或C或D

 

列出檔名為A,B,C,D開頭,並搬至新資料夾

ls |egrep "^[ABCD]" |xargs -i mv {} ./newDir/

 

[ruby]逗號前至少兩個字,逗號後為N或V開頭的字串

\w\w.*,[NV].*$

irc上網友提供

(\w\w.*)(?:,\s*|\()[NV].*

 

#!/usr/X11R6/bin/ruby -Ku
require 'jcode'

farr=Dir["*.DIGEST"]

for i in 0..(farr.size-1)
  File.open("#{farr[i]}") { |file|
   while words=file.gets
      if /\w\w.*,[NV].*/ =~ words then
        File.open("#{farr[i]}.re1","a") { |nline|
          nline.puts  words
        }
      end
   end
  }
end

arrow
arrow
    全站熱搜

    igogo 發表在 痞客邦 留言(0) 人氣()