A sample coffee filter.
$ echo "hi world" | filter.coffee
mi world
$ cat hello.txt
hello world!
$ filter.coffee hello.text
mello world!
#!/usr/bin/env coffee | |
fs = require 'fs' | |
transform = (data) -> | |
result = data.toString().replace /h/g, 'm' | |
process.stdout.write result | |
if process.argv.length > 2 | |
transform fs.readFileSync(file, 'utf8') for file in process.argv[2..] | |
else | |
process.stdin.on 'data', transform | |
process.stdin.resume() |