How to use comm to match log files with same elements, but different timestamps?
Clash 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 :)
comm
add a comment |Â
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 :)
comm
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
add a comment |Â
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 :)
comm
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 :)
comm
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
add a comment |Â
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
add a comment |Â
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 :]
add a comment |Â
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 :]
add a comment |Â
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 :]
add a comment |Â
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 :]
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 :]
edited Feb 18 at 10:18
answered Feb 18 at 5:29
Tigger
1,916812
1,916812
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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