= Ruby = [[https://www.ruby-lang.org/en/|Ruby]] is a general purpose programming language. == Receive data in stdin from pipe == {{{#!highlight ruby #!/usr/bin/ruby # cat records.txt | ruby processrec.rb startRec=false endRec=false records=[] STARTREC="START\n" ENDREC="END\n" EMPTY="" ARGF.each do |line| if line.end_with?(STARTREC) startRec=true end if line.end_with?(ENDREC) endRec=true end if startRec and endRec==false and line.end_with?(STARTREC)==false and line.end_with?(ENDREC)==false records.push(line.gsub(/\n/,EMPTY) ) end if startRec and endRec out=EMPTY records.each do |item| out = "#{out} #{item}" end puts out startRec=false endRec=false records=[] end end }}}