The UNIX and Linux Forums  

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
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 12:16 PM
compare grep? k@ssidy UNIX for Dummies Questions & Answers 7 06-15-2005 12:59 PM
LPP Compare Smoker AIX 2 06-09-2005 02:43 PM
Compare Syed_45 UNIX for Dummies Questions & Answers 2 08-20-2001 04:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-16-2006
sabercats sabercats is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 66
How to compare it ??

Hi how do you compare it in ksh

ALINES=$(cat AFILE | wc -l)
BFIRST=$(head -1 BFILE)

I got ALINES=9 and BFRIST=records'9'

I want 9=9 , how do you write BLINES=9 from records'9' so I can say
ALINES==BLINES


Thanks
  #2 (permalink)  
Old 02-16-2006
mgirinath mgirinath is offline
Registered User
  
 

Join Date: May 2005
Posts: 69
Quote:
Originally Posted by sabercats
Hi how do you compare it in ksh

ALINES=$(cat AFILE | wc -l)
BFIRST=$(head -1 BFILE)

I got ALINES=9 and BFRIST=records'9'

I want 9=9 , how do you write BLINES=9 from records'9' so I can say
ALINES==BLINES


Thanks
If the number always comes in single quotes ' then....try this


Code:
ALINES=$(cat AFILE | wc -l)
BFIRST=$(head -1 BFILE)
BFIRST_NUMBER=`awk -F"'" '{ print $2 }' BFRIST`
then BFIRST_NUMBER will have 9

  #3 (permalink)  
Old 02-16-2006
sabercats sabercats is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 66
It is not working

+ + wc -l
+ cat A
ALINES= 9
+ + head -1 B
BFIRST=records='9'
+ + awk -F' { print $2 } BFIRST
awk: 0602-533 Cannot find or open file BFIRST.
The source line number is 1.
BLINES=
+ print BLINES
BLINES
+ (( ALINES == BLINES ))
t3[7]: ALINES == BLINES : 0403-009 The specified number is not valid for this command.



BFIRST is not a FILE
  #4 (permalink)  
Old 02-16-2006
rajeeb_d rajeeb_d is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 37
ALINES=$(cat AFILE | wc -l)
BFIRST=$(head -1 BFILE)
BFIRST=`echo $BFRIST | cut -d "'" -f 2`
then BFIRST_NUMBER will have 9
  #5 (permalink)  
Old 02-16-2006
rajeeb_d rajeeb_d is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 37
My mistake!
The last line in the last reply was wrong.

ALINES=$(cat AFILE | wc -l)
BFIRST=$(head -1 BFILE)
BFIRST=`echo $BFRIST | cut -d "'" -f 2`
then BFIRST will have 9
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 11:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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