Combine files and delete duplicates using Linux

5 pts.
Tags:
Linux
I need to combine 3 text files and delete the duplicate records after combining them with a single command. What is the best way to do this using Linux?

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Subhendu Sen

    You can use a script for your purpose. For combining multiple files, type as,

    cat file1.txt file2.txt file3.txt > file4.txt

    Next for removing duplicates, type as,

    sort file4.txt | uniq -u

    Now put the both commands in a script file and must give the extension as .sh, (for eg. yourfile.sh) now after saving the file run as,

    ./yourfile.sh

    It is better to keep a backup for all of those files before going to run this commands.

    120,190 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: