The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help! How to compare two lines in a file sabertooth2000 Shell Programming and Scripting 3 04-23-2008 12:26 AM
replacing new lines in all files of a directory containing old lines rooster005 Shell Programming and Scripting 1 03-25-2008 03:38 PM
awk to compare lines of two files and print output on screen chlfc Shell Programming and Scripting 3 03-24-2008 04:16 AM
How to delete first 5 lines and last five lines in all text files ragavendran31 Shell Programming and Scripting 10 02-21-2008 07:58 AM
compare files by lines and columns giviut Shell Programming and Scripting 4 01-17-2008 06:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-19-2007
brdholman brdholman is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 26
Trying to compare lines in 2 files

Hello, I am new to scripting and need some help. In looking at other posts on this forum, I came up with the following logic. I cannot figure out why I am getting names of files of the current directory in my echo output.

Scenario: message file has a line containing the version. Version.txt contains the correct version. I have to see if the message file's version matches the correct version.

Can you tell me what I am doing wrong??


cat /home/brdholman/testing/Tar/Message.dat | while read LINE
do
#if [[ "$LINE" = "$Version.txt" ]]
VERSION="$LINE"
cat Version.txt | while read LINE2
do
if [[ "$LINE2" = "$VERSION" ]]
then
echo $VERSION
else
continue
#echo not equal
fi
done
done
  #2 (permalink)  
Old 09-19-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Post

Try simplifying to this..

Code:
#!/bin/sh

cat /home/brdholman/testing/Tar/Message.dat | while read LINE
do
     VERSION="$LINE"
     cat Version.txt | while read LINE2
     do
          if test "$LINE2" = "$VERSION"
          then
              echo "$VERSION"
          fi
     done
done
I don't think the "continue" adds anything positive.
  #3 (permalink)  
Old 09-20-2007
brdholman brdholman is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 26
No, the continue doesn't. I was using it as a place holder. Thanks.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0