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
for loop problem namishtiwari Shell Programming and Scripting 5 01-25-2008 12:58 PM
loop problem maskot Shell Programming and Scripting 1 05-25-2007 04:10 AM
Problem with for loop/sed ? chiru_h Shell Programming and Scripting 2 08-27-2006 11:55 AM
loop Problem dhananjaysk Shell Programming and Scripting 3 03-31-2006 01:05 PM
problem with while loop mridula High Level Programming 1 12-11-2005 11:44 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-28-2008
The Observer The Observer is offline
Registered User
  
 

Join Date: May 2008
Posts: 18
Problem in For Loop

Hi,
While executing for loop in a shell script , I am getting error.

for i in `cat FILE`
> do
> if [ `cat $i | tr " ' " "\n" | grep ^UNB | cut -f3 -d+ | cut -f1 -d:` -eq WF0000010001 ]; then
> `ls $i` >> /gentran/GIS_42/users/FILES/SENDER_ID
> fi
> done

Error :- ksh[3]: WF0000010001: bad number

Please help me out why this is giving error. I tried many options but invain.

I am using ksh shell.
  #2 (permalink)  
Old 05-28-2008
ripat ripat is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2006
Location: Belgium
Posts: 438
If you want to compare two strings, use the string comparisons operator == instead of the arithmetic operator -eq
  #3 (permalink)  
Old 05-28-2008
siba.s.nayak siba.s.nayak is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 164
Note: It would be better if you use echo instaed cat. and as per RIPAT use string comparision operator in place of -eq and put the string in "".


Regards,
Siba
Quote:
Originally Posted by The Observer View Post
Hi,
While executing for loop in a shell script , I am getting error.

for i in `cat FILE`
> do
> if [ `cat $i | tr " ' " "\n" | grep ^UNB | cut -f3 -d+ | cut -f1 -d:` -eq WF0000010001 ]; then
> `ls $i` >> /gentran/GIS_42/users/FILES/SENDER_ID
> fi
> done

Error :- ksh[3]: WF0000010001: bad number

Please help me out why this is giving error. I tried many options but invain.

I am using ksh shell.
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 11:47 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