1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Duplicate records spool to excel file

Discussion in 'Linux and Unix' started by ron17, Oct 15, 2008.

Thread Status:
Not open for further replies.
  1. ron17

    ron17 Thread Starter

    Joined:
    Oct 15, 2008
    Messages:
    1
    hi,

    i need to identify the duplicate records (in terms of given primary key fields) in a pipe ('|') delimited text file, and spool these duplicates into excel file. i'm illustrating this below:


    input file (in txt file):

    abc|123|jon|male |brown
    xyz|456|may|female|red
    xyz|456|may|female|orange
    klm|234|mac|male |black
    opq|561|may|male |green
    klm|234|ace|male |black
    klm|234|ron|male |black


    output file (in excel format):

    xyz|456|may|female|red
    xyz|456|may|female|orange
    klm|234|mac|male |black
    klm|234|ace|male |black
    klm|234|ron|male |black


    * the 1st two fields are the primary key fields



    thanks!
     
  2. lotuseclat79

    lotuseclat79

    Joined:
    Sep 12, 2003
    Messages:
    20,583
    Hi Ron17,

    Welcome to TSG!

    We are not a homework solving website, but you can learn as you go here.

    Cat the input file into a pipe, |, and use the sort command with '|' as the specified separator field, and specify the key field you are sorting upon, e.g.:
    $ cat input-file | sort ...

    Read the man page for the sort command and play with it until you have solved your problem.
    $ man sort

    -- Tom
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/759347

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice