May 2025posted on 05.02.2025Accessing stdin with file descriptor 0 In Node.js, you can access stdin using file descriptor 0 to take input stream: const fs = require("fs"); const data = fs.readFileSync(0, "utf-8"); This can be used on the Node.js CLI: echo Peter Mekhaeil | node -p "fs.readFileSync(0, 'utf8').toLowerCase().replaceAll(' ','-')" No reactions yet
Accessing stdin with file descriptor 0
In Node.js, you can access
stdinusing file descriptor 0 to take input stream:This can be used on the Node.js CLI: