Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How can I sort a text file eliminating duplicates? i.e sort unique  (Read 25518 times)

0 Members and 1 Guest are viewing this topic.

akondeti

    Topic Starter


    Greenhorn

    Hi,
    Never did dos batch programming.
    I have a text file. I want to sort from column 10 thru 15 and I want to eliminate duplicates. How can i do this?

    Thanks for your help,
    akondeti

    diablo416



      Hopeful
      • Experience: Beginner
      • OS: Unknown
      Re: How can I sort a text file eliminating duplicates? i.e sort unique
      « Reply #1 on: June 30, 2008, 10:52:28 PM »
      duplicates of what? give us an example of the text file

      akondeti

        Topic Starter


        Greenhorn

        Re: How can I sort a text file eliminating duplicates? i.e sort unique
        « Reply #2 on: July 01, 2008, 09:04:47 AM »
        Thanks for responding.

        Here is my file layout (comma delimited)

        Raja,[email protected],732-567-0987
        Sam,[email protected],654-654-8970
        Joda,[email protected],765-987-0987
        Raja1,[email protected],743-546-0987
        Som,[email protected],876-657-9087

        (a)I want to sort the file on field 2 which is the e-mail address
        (b)I want to eliminate duplicates on field 2  i.e e-mail address
        (c)I want to write the output(unique e-mail ids) to a different text file.

        How can i accomplish the above. Thanks in advance for your help.

        ghostdog74



          Specialist

          Thanked: 27
          Re: How can I sort a text file eliminating duplicates? i.e sort unique
          « Reply #3 on: July 01, 2008, 10:17:18 AM »
          no easy way to do that in DOS ( you can try meddling with sort that comes with Windows though). However, here's a simpler way, if you can download GNU sort for windows here

          this is all you need.
          Code: [Select]
          sort  -t"@" -k2,2 file

          akondeti

            Topic Starter


            Greenhorn

            Re: How can I sort a text file eliminating duplicates? i.e sort unique
            « Reply #4 on: July 01, 2008, 11:35:41 AM »
            Hi,
            Thanks for your help. I will try downloading.

            Regards,
            akondeti

            akondeti

              Topic Starter


              Greenhorn

              Re: How can I sort a text file eliminating duplicates? i.e sort unique
              « Reply #5 on: July 02, 2008, 09:40:10 PM »
              Hi,
              i have downloaded the coreutils from GNUWin32 and installed them
              But when i type the following command, it is giving error


              C:\Users\Chola>sort -t "@" -k2,2 email-list.txt
              Input file specified two times.

              (a)After downloading and installing the core utils, do i have to do anything else?

              The GNUWin32 is installed at
              C:\Program Files\GnuWin32

              Please advise.

              The input file has the following records
              Raja,[email protected],732-567-0987
              Sam,[email protected],654-654-8970
              Joda,[email protected],765-987-0987
              Raja1,[email protected],743-546-0987
              Som,[email protected],876-657-9087

              and
              (a)I want to sort the file on field 2 which is the e-mail address
              (b)I want to eliminate duplicates on field 2  i.e e-mail address
              (c)I want to write the output(unique e-mail ids) to a different text file.

              Thanks,
              akondeti

              ghostdog74



                Specialist

                Thanked: 27
                Re: How can I sort a text file eliminating duplicates? i.e sort unique
                « Reply #6 on: July 02, 2008, 10:16:13 PM »
                you have downloaded to C:\Program Files\GnuWin32, however, you are running sort in c:\users\chola without specifying the full path to GNU sort. therefore, the OS is using the sort provided by M$.
                Either provide the full path, or configure your $PATH to include C:\Program Files\GnuWin32. Make sure you put it in front of C:\windows\system32

                Dias de verano

                • Guest
                Re: How can I sort a text file eliminating duplicates? i.e sort unique
                « Reply #7 on: July 04, 2008, 10:17:29 AM »
                I have the core utils, and I have copied the GNU echo.exe to a folder on my PATH and renamed it gnuecho.exe to avoid precisely this problem.

                akondeti

                  Topic Starter


                  Greenhorn

                  Re: How can I sort a text file eliminating duplicates? i.e sort unique
                  « Reply #8 on: July 10, 2008, 10:19:50 PM »
                  O.K
                  I have made changes to my PATH and it is working.

                  Thanks a lot for all your help.

                  Got a quick question though. The gnu core utils does not include grep, the very popular and useful unix command.
                  Is this not a core util? Any way to have grep on windows/dos?



                  Dias de verano

                  • Guest
                  Re: How can I sort a text file eliminating duplicates? i.e sort unique
                  « Reply #9 on: July 11, 2008, 12:19:47 AM »
                  Any way to have grep on windows/dos?

                  The GNU core utils is not the only collection of unix utilities ported to Win32. There are others, including a small set called Unxutils which does have grep.exe

                  http://unxutils.sourceforge.net/

                  ghostdog74



                    Specialist

                    Thanked: 27
                    Re: How can I sort a text file eliminating duplicates? i.e sort unique
                    « Reply #10 on: July 12, 2008, 02:24:45 AM »

                    Got a quick question though. The gnu core utils does not include grep, the very popular and useful unix command.
                    Is this not a core util? Any way to have grep on windows/dos?

                    its' here
                    go to the root URL to see more.