linux guru help, command diff

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • etech
    Confirmed User
    • Feb 2004
    • 1148

    #1

    linux guru help, command diff

    Is there anyone in here who has experience with the command "diff" in linux,
    I have a list with names "names.txt" and i have a list with names that should be removed from "names.txt" and it should generate an output of names.txt with the names from the remove list removed.
  • etech
    Confirmed User
    • Feb 2004
    • 1148

    #2
    anyone ???

    Comment

    • darksoul
      Confirmed User
      • Apr 2002
      • 4997

      #3
      Code:
      cat names.txt removes.txt|sort|uniq -u > newneatnames.txt
      1337 5y54|)m1n: 157717888
      BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
      Cambooth

      Comment

      • etech
        Confirmed User
        • Feb 2004
        • 1148

        #4
        Originally posted by darksoul
        Code:
        cat names.txt removes.txt|sort|uniq -u > newneatnames.txt
        Well this will still leave the second duplicate in the list.

        Comment

        • Superterrorizer
          Confirmed User
          • Sep 2003
          • 509

          #5
          man sort

          Comment

          • JaveWolf
            Registered User
            • Jun 2003
            • 89

            #6
            diff -c <filename> <filename.orig> > whatever.txt
            Don't look here

            Comment

            • darksoul
              Confirmed User
              • Apr 2002
              • 4997

              #7
              Originally posted by etech
              Well this will still leave the second duplicate in the list.
              no it won't.
              1337 5y54|)m1n: 157717888
              BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
              Cambooth

              Comment

              • Brujah
                Beer Money Baron
                • Jan 2001
                • 22157

                #8
                Originally posted by darksoul
                no it won't.
                lol, yes it will.


                you want to use comm, not diff.

                comm -3 names.txt remove.txt > clean.txt

                Usage: comm [OPTION]... FILE1 FILE2
                Compare sorted files FILE1 and FILE2 line by line.

                With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files.

                -1 suppress lines unique to FILE1
                -2 suppress lines unique to FILE2
                -3 suppress lines that appear in both files

                Comment

                • darksoul
                  Confirmed User
                  • Apr 2002
                  • 4997

                  #9
                  Originally posted by Brujah
                  lol, yes it will.
                  lol. no it won't. God I hate ignorant people.

                  Code:
                  gw00# cat test.txt
                  gofuckyourself.com
                  brujah is a wannabe
                  gw00# cat test2.txt
                  gofuckyourself.com
                  gw00# cat test.txt test2.txt|sort|uniq -u
                  brujah is a wannabe
                  1337 5y54|)m1n: 157717888
                  BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
                  Cambooth

                  Comment

                  • Brujah
                    Beer Money Baron
                    • Jan 2001
                    • 22157

                    #10
                    I was wrong. Didn't know the -u option, but the comm command seemed perfect for this. Congrats, you've been a real prick about it. Always good to know who the assholes are.

                    Comment

                    • etech
                      Confirmed User
                      • Feb 2004
                      • 1148

                      #11
                      Both lists will need to be sorted when i use the comm command, right ?

                      Comment

                      Working...