Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:52:01+00:00 2026-06-10T00:52:01+00:00

I have a shell script with the following line to remove double quotes from

  • 0

I have a shell script with the following line to remove double quotes ” from a text file.

sed 's/\"//g' old_file.txt > new_file.txt

There is one more awk statement that selects only a specific columns from a ^ separated text file.

Both the statements are working as expected. But the server hangs when the input file is more than a few GB in size. I will like to know if python can do the same more efficiently.

update:

It is not stopping the server, but mysql hosted on the same server is slow when I run the shell script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:52:02+00:00Added an answer on June 10, 2026 at 12:52 am

    It’s unlikely that Python could do that faster. With a bit work, it could do the same thing with +/- same efficiency. Unless you attempt to do it wrong; because then it will be slower.

    Both sed & awk operate in line mode. They are quite I/O-optimized, and I don’t think you could improve over that. The Python script may be faster if it comes to performing operations but in this case it’s very unlikely to be relevant.

    Just pipe them like @paxdiablo suggests:

    sed 's/"//g' old_file.txt | awk '...' > new_file.txt
    

    Or, if the column format is simple enough, you can replace awk with simpler cut which would be faster:

    sed 's/"//g' old_file.txt | cut -d' ' -f1-2,4 > new_file.txt
    

    (example for columns 1, 2 & 4, space-separated)

    And if you need the intermediate output, you can put tee in the pipeline to write it in the meantime:

    sed 's/"//g' old_file.txt | tee inter_file.txt | cut -d' ' -f1-2,4 > new_file.txt
    

    But it may be actually less efficient since both inter_file.txt and new_file.txt will be written at the same time.


    Ok, now I think I understand what the problem is. Your problem is not that the script is not fast enough because it gets as fast as it can get. It’s your hard drive which hits it throughput limit and thus other applications using it get delayed. You could say that it is simply too fast for you hard drive.

    One solution is to try using ionice to give it lower priority. It may help, it may not make a difference at all.

    ionice -c3 -p$$
    

    gives the lowest (idle) I/O priority to the current shell or script. Similarly, you can start your script with given priority using:

    ionice -c3 ./yourscript.sh
    

    The results may vary upon I/O scheduler used. Some schedulers will ignore this, some may actually make the script slower (whenever mysql will be requesting I/O).

    Alternatively, you could use an additional program which will limit the throughput going to sed, and effectively making it slower and giving some free space for mysql to fit in. You will, however, need to measure what throughput is optimal for you.

    And finally, if none of the above is an option, you could jump in to Python, and add time.sleep() every few hundred or thousand lines to stop the script for a while to let mysql do its job.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a shell script file (run.sh) that contains the following: #!/bin/bash %JAVA_HOME%/bin/java -jar
I have a config file that contains the following line: pre_args='$REGION','xyz',3 Using perl from
I have the following line in a shell script: source bash_profile It does not
I have a shell script with the following code: dir=sample `mkdir $dir` `cp /home/bhavya/workspace/UnetStack/logs/log-0.txt
I have the following line in a shell script: if [ -f /etc/init.d/tomcat6 &&
I have a following line in my shell script. time mysqlshow -u$user -p$password |
I have the following shell script with finds all the files and then should
I am trying a simple shell script like the following: #!/bin/bash up_cap=$( cat result.txt
i have the following shell script- #!/bin/bash echo enter the full path of script;
I have a shell script like this. line=$@ # get the complete first line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.