Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Write to file

  • write

  • Write the content to the file

  • Raise exception if cannot open file for writing

  • e.g. raise File::NotFoundError if parent directory does not exist

if ARGV.size != 2
  puts "Need a filename and the content to write to it on the command line"
  exit 1
end
filename, content = ARGV

File.write(filename, content)