If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Comparing lines in 2 files

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-19-07, 16:37
brdholman brdholman is offline
Registered User
 
Join Date: Nov 2006
Posts: 19
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!
Reply With Quote
  #2 (permalink)  
Old 09-20-07, 02:53
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
grep -f version.txt messagefile.dat || echo "version not the same"
Reply With Quote
  #3 (permalink)  
Old 09-20-07, 07:39
brdholman brdholman is offline
Registered User
 
Join Date: Nov 2006
Posts: 19
Thank you. I will try that out this morning.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On