Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 17: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, 03:53
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 830
grep -f version.txt messagefile.dat || echo "version not the same"
Reply With Quote
  #3 (permalink)  
Old 09-20-07, 08: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

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