How to use comm to match log files with same elements, but different timestamps?

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am new at programming, so please bear with me. I'm trying to use the comm command to compare two logs to see which apps have been installed but not removed. I don't want to use awk for this, if possible. Here's and example of the files:



Installed:



2009-03-21 11:43:21 install flex-old:amd54 <none> 3.7.4a-10ubuntu1
2009-03-22 22:55:08 install libubsan0:amd54 <none> 6.3.0-1ubuntu1~14.04


Removed:



2009-03-24 19:53:49 remove libubsan0:amd54 <none> 6.3.0-1ubuntu1~14.04


So the one that would need to be found as different is the "flex-old" line. Here is what I have tried, with some other variations:



comm -23 <(sort install.txt) <(sort removed.txt) > difference.txt


This outputs all of the installed list, not just the ones that aren't in common with the remove list. I've also tried:



comm -3 <(cut -d " " -4f sort install.txt | uniq) <(sort removed.txt | uniq) > what.txt


But, this outputs all the apps from both, but with the removed directly under the install.
Any help is appreciated :)







share|improve this question




















  • It strikes me that your package manager should be able to tell you what packages are currently installed on the system.
    – Kusalananda
    Feb 18 at 9:14














up vote
0
down vote

favorite












I am new at programming, so please bear with me. I'm trying to use the comm command to compare two logs to see which apps have been installed but not removed. I don't want to use awk for this, if possible. Here's and example of the files:



Installed:



2009-03-21 11:43:21 install flex-old:amd54 <none> 3.7.4a-10ubuntu1
2009-03-22 22:55:08 install libubsan0:amd54 <none> 6.3.0-1ubuntu1~14.04


Removed:



2009-03-24 19:53:49 remove libubsan0:amd54 <none> 6.3.0-1ubuntu1~14.04


So the one that would need to be found as different is the "flex-old" line. Here is what I have tried, with some other variations:



comm -23 <(sort install.txt) <(sort removed.txt) > difference.txt


This outputs all of the installed list, not just the ones that aren't in common with the remove list. I've also tried:



comm -3 <(cut -d " " -4f sort install.txt | uniq) <(sort removed.txt | uniq) > what.txt


But, this outputs all the apps from both, but with the removed directly under the install.
Any help is appreciated :)







share|improve this question




















  • It strikes me that your package manager should be able to tell you what packages are currently installed on the system.
    – Kusalananda
    Feb 18 at 9:14












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am new at programming, so please bear with me. I'm trying to use the comm command to compare two logs to see which apps have been installed but not removed. I don't want to use awk for this, if possible. Here's and example of the files:



Installed:



2009-03-21 11:43:21 install flex-old:amd54 <none> 3.7.4a-10ubuntu1
2009-03-22 22:55:08 install libubsan0:amd54 <none> 6.3.0-1ubuntu1~14.04


Removed:



2009-03-24 19:53:49 remove libubsan0:amd54 <none> 6.3.0-1ubuntu1~14.04


So the one that would need to be found as different is the "flex-old" line. Here is what I have tried, with some other variations:



comm -23 <(sort install.txt) <(sort removed.txt) > difference.txt


This outputs all of the installed list, not just the ones that aren't in common with the remove list. I've also tried:



comm -3 <(cut -d " " -4f sort install.txt | uniq) <(sort removed.txt | uniq) > what.txt


But, this outputs all the apps from both, but with the removed directly under the install.
Any help is appreciated :)







share|improve this question












I am new at programming, so please bear with me. I'm trying to use the comm command to compare two logs to see which apps have been installed but not removed. I don't want to use awk for this, if possible. Here's and example of the files:



Installed:



2009-03-21 11:43:21 install flex-old:amd54 <none> 3.7.4a-10ubuntu1
2009-03-22 22:55:08 install libubsan0:amd54 <none> 6.3.0-1ubuntu1~14.04


Removed:



2009-03-24 19:53:49 remove libubsan0:amd54 <none> 6.3.0-1ubuntu1~14.04


So the one that would need to be found as different is the "flex-old" line. Here is what I have tried, with some other variations:



comm -23 <(sort install.txt) <(sort removed.txt) > difference.txt


This outputs all of the installed list, not just the ones that aren't in common with the remove list. I've also tried:



comm -3 <(cut -d " " -4f sort install.txt | uniq) <(sort removed.txt | uniq) > what.txt


But, this outputs all the apps from both, but with the removed directly under the install.
Any help is appreciated :)









share|improve this question











share|improve this question




share|improve this question










asked Feb 18 at 5:13









rrfeva

1




1











  • It strikes me that your package manager should be able to tell you what packages are currently installed on the system.
    – Kusalananda
    Feb 18 at 9:14
















  • It strikes me that your package manager should be able to tell you what packages are currently installed on the system.
    – Kusalananda
    Feb 18 at 9:14















It strikes me that your package manager should be able to tell you what packages are currently installed on the system.
– Kusalananda
Feb 18 at 9:14




It strikes me that your package manager should be able to tell you what packages are currently installed on the system.
– Kusalananda
Feb 18 at 9:14










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Looks like you were pretty close to me. Based on your samples, the following 1 liner:



comm -23 <(sort install.txt | cut -d" " -f4) <(sort removed.txt | cut -d" " -f4)


Produced this for output for me:



flex-old:amd54


NOTE: You may want to tweak the comm -23. For example, comm -3 may be all you need here.



What I did to test. First, I broke down your commands to test them. I started with:



cut -d " " -4f sort install.txt


Which was clearly broken, so I fixed that to:



sort install.txt | cut -d" " -f4


After that (based on my experience), I was able to re-write your one liner without further testing. If that failed, I would have performed a basic test with comm to see what was wrong, but there was no need this time :]






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f424906%2fhow-to-use-comm-to-match-log-files-with-same-elements-but-different-timestamps%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Looks like you were pretty close to me. Based on your samples, the following 1 liner:



    comm -23 <(sort install.txt | cut -d" " -f4) <(sort removed.txt | cut -d" " -f4)


    Produced this for output for me:



    flex-old:amd54


    NOTE: You may want to tweak the comm -23. For example, comm -3 may be all you need here.



    What I did to test. First, I broke down your commands to test them. I started with:



    cut -d " " -4f sort install.txt


    Which was clearly broken, so I fixed that to:



    sort install.txt | cut -d" " -f4


    After that (based on my experience), I was able to re-write your one liner without further testing. If that failed, I would have performed a basic test with comm to see what was wrong, but there was no need this time :]






    share|improve this answer


























      up vote
      1
      down vote













      Looks like you were pretty close to me. Based on your samples, the following 1 liner:



      comm -23 <(sort install.txt | cut -d" " -f4) <(sort removed.txt | cut -d" " -f4)


      Produced this for output for me:



      flex-old:amd54


      NOTE: You may want to tweak the comm -23. For example, comm -3 may be all you need here.



      What I did to test. First, I broke down your commands to test them. I started with:



      cut -d " " -4f sort install.txt


      Which was clearly broken, so I fixed that to:



      sort install.txt | cut -d" " -f4


      After that (based on my experience), I was able to re-write your one liner without further testing. If that failed, I would have performed a basic test with comm to see what was wrong, but there was no need this time :]






      share|improve this answer
























        up vote
        1
        down vote










        up vote
        1
        down vote









        Looks like you were pretty close to me. Based on your samples, the following 1 liner:



        comm -23 <(sort install.txt | cut -d" " -f4) <(sort removed.txt | cut -d" " -f4)


        Produced this for output for me:



        flex-old:amd54


        NOTE: You may want to tweak the comm -23. For example, comm -3 may be all you need here.



        What I did to test. First, I broke down your commands to test them. I started with:



        cut -d " " -4f sort install.txt


        Which was clearly broken, so I fixed that to:



        sort install.txt | cut -d" " -f4


        After that (based on my experience), I was able to re-write your one liner without further testing. If that failed, I would have performed a basic test with comm to see what was wrong, but there was no need this time :]






        share|improve this answer














        Looks like you were pretty close to me. Based on your samples, the following 1 liner:



        comm -23 <(sort install.txt | cut -d" " -f4) <(sort removed.txt | cut -d" " -f4)


        Produced this for output for me:



        flex-old:amd54


        NOTE: You may want to tweak the comm -23. For example, comm -3 may be all you need here.



        What I did to test. First, I broke down your commands to test them. I started with:



        cut -d " " -4f sort install.txt


        Which was clearly broken, so I fixed that to:



        sort install.txt | cut -d" " -f4


        After that (based on my experience), I was able to re-write your one liner without further testing. If that failed, I would have performed a basic test with comm to see what was wrong, but there was no need this time :]







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 18 at 10:18

























        answered Feb 18 at 5:29









        Tigger

        1,916812




        1,916812






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f424906%2fhow-to-use-comm-to-match-log-files-with-same-elements-but-different-timestamps%23new-answer', 'question_page');

            );

            Post as a guest













































































            Qf iKAjiArC4IU,ZfRoeOvq2H,ZeohaFMIxuf6hGTe6lhd4qS7,ucb1t1pRP4,9CXnT
            7,6P2cp N u

            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            How many registers does an x86_64 CPU actually have?

            Displaying single band from multi-band raster using QGIS