Results 1 to 4 of 4
Hi All,
Hope someone can point me in the right direction.
If you have two text files, we will call them
fileA.txt
fileB.txt
fileA.txt contains a list of usernames that ...
- 07-16-2010 #1Just Joined!
- Join Date
- Jun 2006
- Posts
- 11
File comparision
Hi All,
Hope someone can point me in the right direction.
If you have two text files, we will call them
fileA.txt
fileB.txt
fileA.txt contains a list of usernames that have logged into Apache web server on any given day and the list is small say 5 user names or so.
fileB.txt contains the full list of users authorized to login to Apache web server, say 25 usernames.
What I would like to know, does any user in fileA.txt not exist in fileB.txt and I'm not sure how to do that.
Any ideas greatly appriciated.
Thanks,
Joe
- 07-17-2010 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
well, if you sort both files, then you can use "diff" to show where
they differ: something like this
sort fileA.txt >a
sort fileB.txt >b
diff a b
anything after '<' is unique to file a, i.e. to one.txtthe sun is new every day (heraclitus)
- 07-17-2010 #3Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
How about:
Code:grep -vf fileA.txt fileB.txt
- 08-16-2010 #4Just Joined!
- Join Date
- Jun 2006
- Posts
- 11
Hi All,
Just to post an answer to the problem below:
'comm -23 fileA.txt fileB.txt'
The output will report the uniq username'(s) and nothing else.
Thanks,
Joe
=============================================
If you have two text files, we will call them
fileA.txt
fileB.txt
fileA.txt contains a list of usernames that have logged into Apache web server on any given day and the list is small say 5 user names or so.
fileB.txt contains the full list of users authorized to login to Apache web server, say 25 usernames.
What I would like to know, does any user in fileA.txt not exist in fileB.txt and I'm not sure how to do that.
=================================================


Reply With Quote