Browse | Submit A New Snippet | Create A Package

 

squeeze

Type:
Function
Category:
File Management
License:
GNU General Public License
Language:
Ruby
 
Description:
This function reads the contents of a file, or a list of files, and prints a non-redundant version; the same files with repeated lines removed.

Versions Of This Snippet::

Rory O'Kane
Snippet ID Download Version Date Posted Author Delete
3361.0.12008-01-10 11:23Rory O'Kane
Changes since last version::
Fixed indentation and spacing
21112007-04-18 16:19ruy jauregui

Download a raw-text version of this code by clicking on "Download Version"

 


Latest Snippet Version: :1.0.1

def squeeze 
  ARGV.each{ |f|
    fl = File.new(f).readlines
    fl.uniq!
    esc = File.open("#{f}","w")
    fl.each{ |l| esc.print l}
    esc.close
  }
end
		

Submit a new version

You can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..