Created
February 9, 2009 21:05
-
-
Save timburks/60996 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/local/bin/nush | |
(function append-to-file (filename text) | |
(unless ((NSFileManager defaultManager) fileExistsAtPath:filename) | |
((NSFileManager defaultManager) createFileAtPath:filename contents:nil attributes:nil)) | |
(set handle (NSFileHandle fileHandleForWritingAtPath:filename)) | |
(handle seekToEndOfFile) | |
(handle writeData:((+ text "\n") dataUsingEncoding:NSUTF8StringEncoding)) | |
(handle closeFile)) | |
;; example | |
(append-to-file "mylogfile" (+ "it is now " ((NSDate date) description))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment