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

  • Home
  • SEARCH
  • 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 8843113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:08:15+00:00 2026-06-14T11:08:15+00:00

I have to get certain count from files. The grep statement i am using

  • 0

I have to get certain count from files. The grep statement i am using is like this :

counter_pstn=0
completed_count_pstn=0
rec=0
for rec in `(grep "merged" update_completed*.log | awk '{print $1}' | sed 's/ //g' | cut -d':' -f2)`
do
if [ $counter_pstn -eq 0 ]
then
completed_count_pstn=$rec
else
completed_count_pstn=$(($completed_count_pstn+$rec))
fi
counter_pstn=$(($counter_pstn+1))
done
echo "Completed Orders PSTN Primary " $completed_count_pstn

But the log file contains data in this format :

2500 rows merged.
2500 rows merged.
2500 rows merged.
2500 rows merged.2500 rows merged.
2500 rows merged.
2500 rows merged.

As a result , it is missing out the count of one merge(eg on line 4 of output).How do i modify the grep or use another function to get the count. NOTE that the 2500 number maybe for different logs. So we have to use “rows merged” pattern to get the count. i have tried -o ,-w grep options,but it is not working.

Expected output from above data:

17500

Actual output showing :

15000
  • 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-14T11:08:16+00:00Added an answer on June 14, 2026 at 11:08 am
    perl -p -lne 's/merged./merged.\n/g' your_file|awk '{a+=$1}END{print a}'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java program which is using WMIC to get certain information about
I have this List<string> . How to get certain strings via LINQ? I guessed
I'm trying to get a certain data from mysql with fetchAll. I currently have
I have - class A { // contains certain set() and get() methods }
I have a figure opened with a certain title. How do I get the
This is to be an application-agnostic question, but one I'd like to get a
This is a follow on from another question i made I have this query
I have a table that looks like this: episodes ------------------------------------------------------------ id (PK serial) |
Ok so i have a lil function that will get a value from a
I currently have an asp.net page, that takes in the data from this view

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.