Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2006
    Posts
    19

    Unanswered: Comparing lines in 2 files

    Hello,

    I am a dba turned automation script writer and am writing my first korn shell script.

    Scenario: reading multiple lined message file and if I find the line with the version in it, I need to compare to a version file with one line in it with correct version number. The 2 lines are formatted the same.

    What I tried:
    cat /home/userfolder/testing/Tar/Messagefile.dat | while read LINE
    do
    #if [[ "$LINE" = "$Version.txt" ]]
    if [[ "$LINE" = ' * Software name Version n.n.nnn' ]]
    then
    echo $LINE
    fi
    done

    1) assigned file name to variable and compare the value. Couldn't find the file.
    2) Put in the name of the file to compare to (I think this bombed due to not 'READ'ing the Version.txt file.
    3) put the literal in the comparison.

    Result: None worked.

    Questions:
    1. How do I correctly assign a file to a variable.
    2. Is there an issue since there is a * in the line?

    Thanks in advance!

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    grep -f version.txt messagefile.dat || echo "version not the same"

  3. #3
    Join Date
    Nov 2006
    Posts
    19
    Thank you. I will try that out this morning.

Posting Permissions

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