Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file_name = ARGV[0]
- if file_name == nil
- abort "Введите имя файла, как параметр"
- end
- current_path = File.dirname(__FILE__)
- file_path = current_path + "/test.txt"
- if File.exist?(file_path)
- # file = File.new(file_path, "r:UTF-8")
- puts "Вы открыли файл - #{file_path}"
- lines = File.readlines(file_path)
- puts "Всего строк в файле: #{lines.size}"
- empty_lines = []
- for line in lines do
- if line == "\n"
- empty_lines.push("")
- end
- end
- puts "Количество пустых строк: #{empty_lines.size}"
- puts "Последние пять строк:"
- puts
- puts lines.last(5)
- else
- puts "Файла нет"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement