Find the answer to your Linux question:
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 ...
  1. #1
    Just 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

  2. #2
    tpl
    tpl is offline
    Linux 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.txt
    the sun is new every day (heraclitus)

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    How about:

    Code:
    grep -vf fileA.txt fileB.txt

  4. #4
    Just 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.
    =================================================

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...