我可以获取文件内容并将其拆分,但是如何将第5行更改为其他内容?
你怎么能打电话给线路?结果看起来像这样:
const fs = require("fs)
fs.readFile('./some/path/file.js', 'utf8', function read(err, data) {
if(err) {
console.log(err)
}
content = data;
});
var something = \n
var result = content.split(something)
//now ho can i get all the lines before 5 and all the lines after 6?
var 5 = //lines before 6
var 6 = //lines after six
//so i could just do
var final = 5 + \n + result + 6 + \n + result //???
//so it would be a one variable again
console.log("one variable " + final)