Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2014
    Posts
    3

    Unanswered: Diff Command In linux

    Hi,
    I have 2 files for which i need to find the difference.
    Data will be something like this.
    File 1)
    User Roles
    admin
    guest

    File 2)
    User Roles
    admin
    john
    guest

    If i use the command Diff File1 File > output.txt ,then i get the difference but the header will be missing.
    How can we get the header also in the output file.(header will be same in both the files)
    Thanks

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    head -n1 file1 >output.txt
    diff file1 file2 >>output.txt
    Unfortunately as you will see, the contents of output.txt is not
    user roles
    john
    but rather

    user roles
    2a3
    > john


Tags for this Thread

Posting Permissions

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