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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:02:06+00:00 2026-06-02T02:02:06+00:00

I have a log file ( file.log ) with multiple occurrences of ids i.e.

  • 0

I have a log file (file.log) with multiple occurrences of ids i.e. 82244956 in a file.
file.log has been created using the command :

gzip -cd /opt/log.gz | grep "JBOSS1-1" >> ~/file.log

Example :

2012-04-10 09:01:18,196 LOG  (7ysdhsdjfhsdhjkwe:IN) JBOSS1-1 (RP-yedgdh5567) [PayPalWeb] Fetch data with id: 82244956  
2012-04-10 09:02:18,196 LOG  (24343sdjjkidgyuwe:IN) JBOSS1-1 (RP-yedgdh5567) [PayPalWeb] Fetch data with id: 82244956  
2012-04-10 09:03:18,196 LOG  (6744443jfhsdgyuwe:IN) JBOSS1-1 (RP-yedgdh5567) [PayPalWeb] Fetch data with id: 82244957  
2012-04-10 09:04:18,196 LOG  (7ysdhsd5677dgyuwe:IN) JBOSS1-1 (RP-yedgdh5567) [PayPalWeb] Fetch data with id: 82244957  

Likewise we have 10000 rows with different ids (but each id repeating 2-3 times. Example top and bottom 2 rows in this example are repeating with id 82244956 and 82244957 respectively). We need result set based on UNIQUE ids (any row from the matched ids)i.e.:

2012-04-10 09:01:18,196 LOG  (7ysdhsdjfhsdhjkwe:IN) JBOSS1-1 (RP-yedgdh5567) [PayPalWeb] Fetch data with id: 82244956  
2012-04-10 09:03:18,196 LOG  (6744443jfhsdgyuwe:IN) JBOSS1-1 (RP-yedgdh5567) [PayPalWeb] Fetch data with id: 82244957  

I tried to awk program on Linux but not a successful one :

awk ' { arr[$1]=$0 } END { for ( key in arr ) { print arr[key] } } ' file.log >> final-report.log

Or a better way would be to create file.log with distinct ids Only.

Please advise how can I modify it?

  • 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-02T02:02:08+00:00Added an answer on June 2, 2026 at 2:02 am

    $1 is the first field, the date. The id is the last field, $NF in awk parlance. So:

    awk '{arr[$NF] = $0} END { for (key in arr) { print arr[key] } }' file.log >> final-report.log
    

    This keeps the last record with the given key. To keep the first record, you’d have to do a conditional assignment in the main processing part of the script.

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

Sidebar

Related Questions

If i have file for eg: a log file created by any background process
I have a log file which has a format of this kind: DATE-TIME ###
I have a log file (.txt) which has information as below: Filename1 - A3332NCDER
I have a big log file with multiple lines separated by new line. Each
I have a log file in SqlServer that stores the time an application started,
I have a log file containing statistics from different servers. I am separating the
Lets say we have a log file (preferably a txt file) available in the
I have a transaction log file in CSV format that I want use to
I have a huge log file where there are about 15 million lines. I
I have a log.txt file on the root of my application. I would like

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.