Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
Delete the first 25 lines of a .txt document

I want to delete the first 25 lines of text from a .txt bots document every time when I use a command on my discord server (I know how to do that by command but I dont know how to delete the rows)

var text = fs.readFileSync("./data/bots.txt", "utf-8");
var bot = text.split("\n")

btw I cant skip them every 25 first lines because the bots file is 10.000 lines long and every time a bot is used it should be deleted from the docs

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Under the assumption that each line is separated by a new line, I would:

  1. Read file
  2. Form array, split by new line
  3. Return lines 25 -> End
  4. Change from array back to string
  5. Write new file

So I'd do this with nodejs:

const fs = require("fs")
const text = fs.readFileSync("./data/bots.txt", "utf8");
const textArr = text.split("\n");
// This removes the 25th line as well, if you want to keep it
// change it to 24
const textArrNew = textArr.slice(25);
const string = textArrNew.join("\n");
fs.writeFileSync("new2.txt", string);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda