file = open("xxx")
例
file = open(ARGV[0]) ### 第一引数のファイルを開く
file.each do |line|
puts line
end
または
file = open(ARGV[0]) ### 第一引数のファイルを開く
while data=file.gets
puts data
end
file.close
File.open("xxx")
例
File.open(ARGV[0]).each do |line|
puts line
end
file = open("xxx","w")
例
file = open(ARGV[0],"w")
file.puts "aaa"
file.close
open("xxx","w")
例
open(ARGV[0],"w") { |file|
file.puts "aaa"
}
※存在するファイルは上書きされます
open("xxx","a")とすればいい