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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:18:11+00:00 2026-06-13T13:18:11+00:00

I use grep to return unmatched array between temporaryF file and arrayWarning my @c

  • 0

I use grep to return unmatched array between temporaryF file and arrayWarning

my @c =grep!${{map{$_,1}@temporaryF}{$_},@arrayWarning;

Inside @c there are alot of lines for example:

Sun Sep 30 00:05:55 fibre channel DENY forever
Sun Sep 30 00:06:55 fibre channel ROOT cause
Sun Sep 30 00:08:55 fibre channel ROOT cause 
Sun Sep 30 00:10:55 fibre channel ROOT cause  
Sun Sep 30 00:20:55 fibre channel DANN 
Sun Sep 30 00:30:55 fibre channel DANN  

as you can see ROOT occurs 3 times in @c. How can I iterate through @c to output only the latest occurrence of ROOT -> Sun Sep 30 00:10:55 fibre channel ROOT
and not the other repeated lines.

so it will become:

Sun Sep 30 00:05:55 fibre channel DENY forever  
Sun Sep 30 00:10:55 fibre channel ROOT cause  
Sun Sep 30 00:30:55 fibre channel DANN
  • 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-13T13:18:13+00:00Added an answer on June 13, 2026 at 1:18 pm

    Note: this is an extension of the answer of @RobEarl – so if you like it, please make sure to give him credits, too!

    The point here is to store the line count too, to make sure the output can be ordered.

    Long version

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    # store (with count)
    my $count  = 0;
    my %latest = map {
        my $source = (split /\s+/ => $_)[6];
        $source => {count => $count++, string => $_};
    } <DATA>;
    
    # output
    print $_->{string} for sort {$a->{count} <=> $b->{count}} values %latest;
    
    __DATA__
    Sun Sep 30 00:05:55 fibre channel DENY forever
    Sun Sep 30 00:06:55 fibre channel ROOT cause
    Sun Sep 30 00:08:55 fibre channel ROOT cause 
    Sun Sep 30 00:10:55 fibre channel ROOT cause  
    Sun Sep 30 00:20:55 fibre channel DANN 
    Sun Sep 30 00:30:55 fibre channel DANN  
    

    Output:

    Sun Sep 30 00:05:55 fibre channel DENY forever
    Sun Sep 30 00:10:55 fibre channel ROOT cause  
    Sun Sep 30 00:30:55 fibre channel DANN  
    

    Feels a little bit like the Schwartzian transform.

    One-liner version

    This is an excellent example for a task that can be accomplished by a simple oneliner with perl’s powerful interpreter switches:

    $ perl -nale '$l{$F[6]}={c=>$c++,s=>$_};END{print$_->{s}for sort{$a->{c}<=>$b->{c}}values%l}'
    Sun Sep 30 00:05:55 fibre channel DENY forever
    Sun Sep 30 00:06:55 fibre channel ROOT cause
    Sun Sep 30 00:08:55 fibre channel ROOT cause 
    Sun Sep 30 00:10:55 fibre channel ROOT cause  
    Sun Sep 30 00:20:55 fibre channel DANN 
    Sun Sep 30 00:30:55 fibre channel DANN  
    

    Output:

    Sun Sep 30 00:05:55 fibre channel DENY forever
    Sun Sep 30 00:10:55 fibre channel ROOT cause  
    Sun Sep 30 00:30:55 fibre channel DANN  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We can use grep to return the lines with matched words, but how to
Is it possible to use grep to match only lines with numbers in a
What command, or collection of commands, can I use to return all file extensions
On Linux, I often use grep with context to find usage information in man
I'm trying to use ack-grep as a replacement for grep + find in Emacs
I usually use the following pipeline to grep for a particular search string and
Background: sometimes I use ps aux | grep process_name to figure out some statistics
I am trying to use a regular expression with grep command of Linux (^\s*\*\s*\[
I know I can use the -n flag in git grep to show the
I'm having trouble with grep.. Which four patterns should I use with PHP's preg_grep

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.