Find the answer to your Linux question:
Results 1 to 8 of 8
I have wriiten a bash script for comparing 2 files using diff and enscipt. The output is to be shown side-by-side without showing the common portion in the second file. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2005
    Posts
    4

    Comparing file side by side


    I have wriiten a bash script for comparing 2 files using diff and enscipt. The output is to be shown side-by-side without showing the common portion in the second file. The problem is some lines of the second file is getting wrapped and it appears as part of the first file. Is there any way out to align the wrapped text along with the second file? Thanks.

    Commands used within the bash script are
    diff --side-by-side -y -t --width=300 file1 file2 > outfile
    enscript -p psfilename --margins=1:1:1:1 -r -fCourier7 --word-wrap outfile

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Why not just use the comm utility with the -3 option, which supresses lines that are common to each file?

  3. #3
    Just Joined!
    Join Date
    Dec 2005
    Posts
    4
    thanks, but my requirement is to take a print of that and review. So, i cannot supress common lines. My output is fine, only problem is that some of the lines that are not common, and is part of the second file is getting wrapped and it goes as part of the first file. I require that to appear along with the second file as it should be. please advice.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    I really don't understand you.

  6. #5
    Just Joined!
    Join Date
    Dec 2005
    Posts
    4
    sample output of my script

    current output (here the 'in java' is getting wrapped and comes as as part of the first file)
    ===============================================
    This is a sample program (
    comparing two files in perl < comparing two file
    in java
    Test completed (

    Expected output('in java' should be part of the second file)
    ===============================================
    This is a sample program (
    comparing two files in perl < comparing two files in java
    Test completed (

  7. #6
    Just Joined!
    Join Date
    Apr 2005
    Posts
    23
    doesnt enscript allow you to specify a two column format? if so, try writing one file to one coloman and the other file to the other column.

  8. #7
    Just Joined!
    Join Date
    Dec 2005
    Posts
    4
    enscript has 2 columns option, but how will it consider the output from diff as 2 different files. And if thru enscript i am able to show the 2 actual files in 2 different columns, then how would i see the differences between these 2 files?

  9. #8
    Just Joined!
    Join Date
    Apr 2005
    Posts
    23
    I think you're just going to have to capture the output and manually format it. If text is wrapped, you'll have to add the correct number of spaces to the new line.

Posting Permissions

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