Created
May 27, 2011 17:21
-
-
Save seungjin/995721 to your computer and use it in GitHub Desktop.
add my first line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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