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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:42:35+00:00 2026-06-03T23:42:35+00:00

I need to slice several TB of log data, and would prefer the speed

  • 0

I need to slice several TB of log data, and would prefer the speed of the command line.
I’ll split the file up into chunks before processing, but need to remove some sections.

Here’s an example of the format:

uuJ oPz eeOO    109 66  8
uuJ oPz eeOO    48  0   221
uuJ oPz eeOO    9   674 3
kf iiiTti oP    88  909 19
mxmx lo uUui    2   9   771
mxmx lo uUui    577 765 27878456

The gaps between the first 3 alphanumeric strings are spaces. Everything after that is tabs. Lines are separated with \n.

I want to keep only the last line in each group.

If there’s only 1 line in a group, it should be kept.

Here’s the expected output:

uuJ oPz eeOO    9   674 3
kf iiiTti oP    88  909 19
mxmx lo uUui    577 765 27878456

How can I do this with sed, awk, xargs and friends, or should I just use something higher level like Python?

  • 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-03T23:42:37+00:00Added an answer on June 3, 2026 at 11:42 pm

    Try this:

    awk 'BEGIN{FS="\t"}
        {if($1!=prevKey) {if (NR > 1) {print lastLine}; prevKey=$1} lastLine=$0}
        END{print lastLine}'
    

    It saves the last line and prints it only when it notcies that the key has changed.

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

Sidebar

Related Questions

For an app that I am writing I need to display several views (in
I'm trying to get a block of code down to one line. I need
I have a slice of a circle (that is made of moveTo,lineTo,arc,etc) and need
I need to slice this image in css to use as background http://i28.lulzimg.com/f0f166e559.png but
I have several div tags containing simple html/css content and I need a simple
When we need to slice a string at a particular location, we need to
I have an application that writes several billion records into Cassandra and removes duplicates
I'm using C# and SQLite to slice large amounts of data, and I often
I'm using a 2 processes Pool to parallel parse several log files, po =
I have some non-trivial computational code that need to be applied on data already

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.