Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Last active December 16, 2015 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joyrexus/5368680 to your computer and use it in GitHub Desktop.
Save joyrexus/5368680 to your computer and use it in GitHub Desktop.
Sample unix-style filter that reads from STDIN sans args.
#!/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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment