Find the answer to your Linux question:
Results 1 to 4 of 4
Hi folks, I'm going to make a script checking inconsistence on 2 documents Doc-BBB is reproduced from Doc-A, (original document) not with 'copy and paste' command. Making it simple first, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,814

    Script to check Doc-BBB against Doc-AAA for inconsistence


    Hi folks,

    I'm going to make a script checking inconsistence on 2 documents

    Doc-BBB is reproduced from Doc-A, (original document) not with 'copy and paste' command.

    Making it simple first, as highlighted in following example, an one line document:-

    Doc-AAA
    Code:
    Check this link to sea what scannars are supported by SANE
    Doc-BBB
    must be reproduced exactly the same as Doc-AAA, disregarding the typing mistake (spelling mistake)
    sea = should read “see”
    scannars = should read “scanners”
    in order to make sense.

    That is to check Doc-BBB to be 100% consistent to Doc-AAA even spelling mistake existing. If a mistake is found on Doc-BBB the mistake will be printed out in pair, such as;

    Code:
    Doc-AAA   Doc-BBB
    sea       sei
    character “i” will be highlighted or changed to another colour and its line number and word number also indicated..

    Can any folk shed me some light how to start?

    TIA

    B.R.
    satimis

  2. #2
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    Start with this:
    Code:
    file1="myfile"
    file2="anotherfile"
    
    if [ `cmp -s $file1 $file` -eq 1 ] ; then
           diff $file1 $file2
    fi
    You use this on files that are expected to be different only rarely.
    IF almost every file pair you test is different just use
    Code:
    diff myfile anotherfile

  3. #3
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    Start with this:
    Code:
    file1="myfile"
    file2="anotherfile"
    
    if [ `cmp -s $file1 $file` -eq 1 ] ; then
           diff $file1 $file2
    fi
    You use this on files that are expected to be different only rarely.
    IF almost every file pair you test is different just use
    Code:
    diff myfile anotherfile

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,814
    Hi jim mcnamara,

    Tks for your advice. Tests performed as follows;

    1)
    Original document "doc_a"
    Code:
    Check this link to sea what scannars are supported by SANE
    Already having 2 typing mistakes
    sea
    scannars

    2)
    But the reproduced document "doc_b" must maintain these 2 mistakes for consistence.
    Code:
    check thes link to sea what scannars are suppurted by SeNE
    Unfortunately another 3 typing mistakes were further made;
    thes
    suppurted
    SeNE

    Steps taken:
    $ touch compare
    $ nano compare
    Code:
    #!/bin/bash
    set -x
    
    file1="doc_a"
    file2="doc_b"
    
    if [ `cmp -s $file1 $file` -eq 1 ] ; then
           diff $file1 $file2
    fi
    $ chmod +x compare
    $ ./compare
    Code:
    + file1=doc_a
    + file2=doc_b
    ++ cmp -s doc_a
    It hung here.

    $ diff doc_a doc_b
    It only printed out the content of doc_a and doc_b. I have tried the options on --help

    What I expect to have in the printout is;
    Code:
    Original    Mistake   Line No.   Word No.
    this        thes      1          2
    supported   suppurted 1          9
    SANE        SeNE      1          11
    not just printing out their contents and saying "differ"

    B.R.
    satimis

Posting Permissions

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