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
how to specify the amount of RAM to use for a script in linux

Let's say I want to edit all the files in a folder, changing every header. I'm using this script:

for thing in $(ls $1); do sed -i '1c\SNP A2 A1 beta N P' $thing done

The problem is that it takes a lot of time. So, I'd like to find a way to dedicate more RAM for this script, in order to do it quickly. Is it possible?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I'd like to find a way to dedicate more RAM for this script, in order to do it quickly. Is it possible?

No. The tools you use, bash to enumerate your files and sed to edit them, take the RAM they need to do their work. They can't use more RAM even if they had a way to give it to them.

You can run your sed operations in parallel. This uses more cores on your machine and may finish faster. Put an & character after each command in the loop. Something like this.

for thing in $(ls $1); do 
  sed -i '1c\SNP A2 A1 beta N P' $thing &
done
over 4 years ago · Santiago Trujillo Report

0

With GNU Parallel you can control how many are run in parallel:

doit() {
  sed -i '1c\SNP A2 A1 beta N P' "$1"
}
export -f doit
ls $1 | parallel -j5 doit 

Adjust -j5 until you find the number that gives you most throughput.

over 4 years ago · Santiago Trujillo 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!