Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-24-2012
bmk bmk is offline
Registered User
 
Join Date: Dec 2011
Posts: 258
Thanks: 1
Thanked 22 Times in 22 Posts
value compare

Hi,

file contains only one row.


Code:
END OF FILE. ROW COUNT: 8,9

We need to check the file contains exact string "END OF FILE. ROW COUNT: " if yes, get the 8,9 values
then compare if both are equal print the "equal" if not "notequal".

Thanks,
Sponsored Links
    #2  
Old 05-24-2012
Moderator
 
Join Date: Feb 2007
Location: The Netherlands
Posts: 7,505
Thanks: 73
Thanked 474 Times in 453 Posts

Code:
awk -F"[ ,]" '/END OF FILE/{print $NF != $(NF-1)?"notequal":"equal"}' file

Sponsored Links
    #3  
Old 05-24-2012
bmk bmk is offline
Registered User
 
Join Date: Dec 2011
Posts: 258
Thanks: 1
Thanked 22 Times in 22 Posts
Thanks,as per validation it should come equal,it coming as "notequal",but i need implement the in script,if equal got to one step else another step...

Please help me
    #4  
Old 05-24-2012
elixir_sinari's Avatar
Gotham Knight
 
Join Date: Mar 2012
Location: India
Posts: 1,372
Thanks: 87
Thanked 477 Times in 457 Posts
Something like this?


Code:
sed -n 's|^END OF FILE. ROW COUNT: \([0-9]\{1,\}\),\([0-9]\{1,\}\)|\1 \2|p' <filename>|read num1 num2

if [ ! -z "$num1" -a ! -z "$num2" ]
then
 if [ $num1 -eq $num2 ]
 then
  echo Equal
 else
  echo Not equal
 fi
fi

Sponsored Links
    #5  
Old 05-24-2012
bmk bmk is offline
Registered User
 
Join Date: Dec 2011
Posts: 258
Thanks: 1
Thanked 22 Times in 22 Posts
Thanks lot working fine...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Require compare command to compare 4 files nehashine Shell Programming and Scripting 6 08-27-2010 07:29 AM
Compare kezkez Shell Programming and Scripting 1 07-13-2010 08:01 PM
Compare two arrays in sh or compare two fields rijeshpp Shell Programming and Scripting 0 10-31-2007 02:47 AM
compare two tar.bz2 JCR Shell Programming and Scripting 2 07-30-2007 11:16 AM
How to compare it ?? sabercats Shell Programming and Scripting 4 02-16-2006 05:07 PM



All times are GMT -4. The time now is 06:15 AM.