Answer the question
In order to leave comments, you need to log in
How to get the first 10 lines from a text file and remove them from there?
I have a .txt file with lines:
123123
123123
aaa12123
asdasasd123...
I need to take N number of lines from the beginning, write them to a variable and immediately delete them from the file. I will be very grateful for help.
Answer the question
In order to leave comments, you need to log in
const fs = require('fs')
try {
const data = fs.readFileSync('/Users/joe/test.txt', 'utf8')
console.log(data)
} catch (err) {
console.error(err)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question