Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created May 27, 2011 17:21
Show Gist options
  • Select an option

  • Save seungjin/995721 to your computer and use it in GitHub Desktop.

Select an option

Save seungjin/995721 to your computer and use it in GitHub Desktop.
add my first line
my_first_line = "#!/home/seungjin/opt/python-2.6.6/bin/python\n"
ARGV.each do |file|
#file exist?
if ! File.exist?(file)
puts "File #{file} does not exist"
exit
end
File.open(file,'r+') { |f|
lines = f.readlines
f.pos = 0
f.print my_first_line
f.print lines
f.truncate(f.pos)
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment