I have the following text file ("test.txt") that I want to manipulate in node.js:
world food
I want to delete the first line so that it is instead food. How can i do this?
food
var fs = require('fs') fs.readFile(filename, 'utf8', function(err, data) { if (err) { // check and handle err } var linesExceptFirst = data.split('\n').slice(1).join('\n'); fs.writeFile(filename, linesExceptFirst); });
Source: https://habr.com/ru/post/1650625/More articles:Docker container health check command (1.12) (not in Docker file!) - dockerNode.JS Express 4 - Mongoose Doesn't Save Data - node.jsjava.lang.NoSuchMethodError: org.apache.tomcat.util.res.StringManager.getManager with tomcat in Spring hetos - javaDifference between transform: translate3d (50%, 0,0) and left: 50% in css? - cssd3 V4.2.1 TypeScript Ошибка 2.0 импорта d3-selection-multi - typescriptPass data from html body to root component - angularC # SELECT statement, SQL query - c #abs() и альтернативный простой оператор if, похоже, не работает - c++Getting a model with nested complex types from Azure Mobile Apps - entity-frameworkКак я могу исправить перекрывающиеся разделы в компоновщике script с помощью команды phdrs? - cAll Articles