Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda