Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!