@
@
@estoniec2021-10-09 00:28:27
Command line
@estoniec, 2021-10-09 00:28:27

How to save console.log to a separate file?

This is the code that needs to be saved in a separate file (more precisely, the output to the console)

const uuid = _ => 'xxx_xxx_00_00'.replace(/x|0/g, v => v === 'x'
    ? String.fromCharCode(Math.floor(Math.random() * 26) + 97)
    : Math.floor(Math.random() * 10))
console.log(uuid());


the output itself to be output is xxx_xxx_xx_xx
PS D:\bat> node gg.js
lcn_ljo_13_77

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fedor Vlasenko, 2021-10-09
_

const fs = require('fs')
const uuid = _ => 'xxx_xxx_00_00'.replace(/x|0/g, v => v === 'x'
    ? String.fromCharCode(Math.floor(Math.random() * 26) + 97)
    : Math.floor(Math.random() * 10))
fs.appendFileSync('code.log', `${uuid()}\n`);

Option

A
Aetae, 2021-10-09
@Aetae

node gg.js > file.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question