dimanche 1 mars 2015

Ruby-Reading a specific line from file

$TENANT=gets.chomp('/\p{Alnum}/')


$first = $TENANT.slice(0,1).capitalize


$second = $TENANT.slice(1..-1)


EXPORT_PASSWORD="Export-"+ $first + $second.chomp + "!"


EXPORT_FILENAME=$TENANT.chomp + ".xar"


file = File.open("/Users/..../input/exporttenant.rb", "r") contents = file.read puts content


output = File.open(/.../input/$TENANT.txt, "w") $TENANT=tenant_name


In these I will read full contents of the file. but I want to read only DS_ENTRY(line) from that file. I want that line to print to new file it should be created by $TENANT(variable-name in that directory-/Users/..../input/$TENANT)and I want to print previously declared variables


Aucun commentaire:

Enregistrer un commentaire