Results 1 to 4 of 4

Thread: Printing unique lines in the Linux

  1. #1
    Join Date
    Dec 2010
    Posts
    299

    Printing unique lines in the Linux

    Recently I have begun to use with Linux. Well it’s a great operating system. If there 10 lines in the files how will I print the unique line from that file. I don’t require to similar line on the screen. I am here because many of you are familiar with the Linux. I thought I will definitely get solution from you. If you have any suggestion please let me know. I will be really thankful to you. Please tell me appropriate solution as soon as possible.

  2. #2
    Join Date
    May 2008
    Posts
    962

    Re: Printing unique lines in the Linux

    Well looking at your situation I am suggesting you to use grep command. This command is used for searching of the text in the file. You can provide every single line of the file to the command. It will count the total number of similar line the file. If the total count is one then it will echo the line on the screen. I think grep command will definitely solve your problem. Thanking you for the reading the solution.

  3. #3
    Join Date
    May 2008
    Posts
    1,020

    Re: Printing unique lines in the Linux

    I am suggesting you to use Sort command to get the appropriate results. ‘sort’ command sorts the line according to argument list provided. You have to use the following code sort <file> | uniq. ‘sort’ will sort the file and ‘uniq’ command will extract t unique line from the file. It is another great solution for you. If it does not working for you can follow other forums also on the internet. Try your Luck!. It may help you.

  4. #4
    Join Date
    Nov 2009
    Posts
    825

    Re: Printing unique lines in the Linux

    You can use ‘sort’ command in more efficient manner as below. Type following command on the terminal sort –u somefile | lpr’. You have to sort the file and the desired output is redirected to lpr. On above example somefile is source file and the lpr is the destination file where output is redirected. I want to say thank you to all of you for replying and suggesting idea on this matter. I really want to appreciate your efforts that you have put in.

Similar Threads

  1. What is unique about the Linux
    By Kavanagh in forum Operating Systems
    Replies: 4
    Last Post: 06-02-2012, 08:31 PM
  2. Replies: 2
    Last Post: 11-11-2011, 05:54 PM
  3. Printing MPP files to Adobe and then printing on paper
    By mbbackus in forum Microsoft Project
    Replies: 2
    Last Post: 28-09-2011, 06:10 PM
  4. Printing With Lexmark X5320 connected with Linux Mint 10
    By NamJam in forum Portable Devices
    Replies: 3
    Last Post: 02-01-2011, 07:17 AM
  5. SQL UNIQUE and DISTINCT
    By Taarank in forum Software Development
    Replies: 5
    Last Post: 10-05-2010, 10:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •