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 8032609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:26:17+00:00 2026-06-05T01:26:17+00:00

I have a file containing queries, each query ends with a ;, I want

  • 0

I have a file containing queries, each query ends with a “;”, I want to add a “COMMIT;BEGIN;” every 100 queries. Queries can take more than 1 line.

For instance:


    INSERT INTO table
    VALUES(...);
    DELETE FROM table WHERE ...;
    UPDATE table
    SET ...;

So I want to replace every 100th ";" with "COMMIT;BEGIN;" (I know I have to add a BEGIN; at the beginning of the file and do something at the end but it's easy)

I need to do that in a shell script but I am not a Linux expert, is it better to use sed or awk (also the file size can be huge like 4GB)? I know the basics for those commands but I don't know if I can do what I want here...

Thanks!

  • 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-05T01:26:19+00:00Added an answer on June 5, 2026 at 1:26 am

    If you can guarantee that the ; is at the end of the line, or if you don’t really care about lines with multiple ;‘s, the easy solution (untested) is:

    awk '/;/{ count+=1 } {print} count==100 { print "COMMIT; BEGIN"; count=0 }'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .sql file containing a bunch of SQL queries, with each query
I have a .SQL file containing a large number of queries. They are being
I have a file containing vectors of data, where each row contains a comma-separated
I have a file containing ~20 million lines (~1.5GB). Each line is of the
I have a log file containing search queries entered into my site's search engine.
I have a file containing N*10 lines, each line consisting of a number. I
If I have a file containing some escaped parens, how can I replace all
I have a file containing text in separate line. I want to display line
I have a file containing a pickled list of lists of floats. I can
I have file containing a list of files separated by end of lines $

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.