Skip to content

Instantly share code, notes, and snippets.

@soldair
Created August 22, 2012 22:12
Show Gist options
  • Save soldair/3429947 to your computer and use it in GitHub Desktop.
Save soldair/3429947 to your computer and use it in GitHub Desktop.
nodejs oneliner to reverse text on all lines of /etc/passwd from stdin to stdout
cat /etc/passwd | node -e "var buf ='',rev=function(lines){lines.forEach(function(l,k){process.stdout.write(l.split('').reverse().join('')+'\n')})};process.stdin.on('data',function(b){buf+=b.toString();b = buf.split('\n');buf = b.shift();rev(b)}); process.stdin.resume();"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment