The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
If statement - How to write a null statement april Shell Programming and Scripting 3 04-16-2008 10:14 AM
logical OR in sed anchal_khare Shell Programming and Scripting 8 02-08-2008 12:38 AM
(sed) parsing insert statement column that crosses multiple lines jjordan Shell Programming and Scripting 3 10-08-2007 09:23 PM
Multiple Logical Operator Issues ... srikanthgr1 Shell Programming and Scripting 1 05-14-2007 04:27 AM
Logical AND within a case statement ?? hcclnoodles Shell Programming and Scripting 1 11-10-2006 11:27 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-03-2006
Registered User
 

Join Date: Aug 2006
Posts: 45
multiple Logical statement

hi I have following if condition
line_by_line="0000000000000ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt ttttttt"

if [ `expr substr "$line_by_line" 1 13` == "0000000000000" ]
then
echo "Exclusion criteria"
else
echo "Not exclusion criteria"
fi
above condition works perfectley but if i add one more logical condition as below
line_by_line="00000000000000000000000000tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttt"

if [ `expr substr "$line_by_line" 1 13` == "0000000000000" || `expr substr "$line_by_line" 26 12` == "UA ITEM FROM" ]
then
echo "Exclusion criteria"
else
echo "Not exclusion criteria"
fi

it throws the error as
test_script.sh: line 4: tttttttttttt: command not found

any clue on above error
Reply With Quote
Forum Sponsor
  #2  
Old 10-03-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
try this

Code:
if [ `expr substr "$line_by_line" 1 13` == "0000000000000" -o `expr substr "$line_by_line" 26 12` == "UA ITEM FROM" ]
or

Code:
if [ `expr substr "$line_by_line" 1 13` == "0000000000000" ] || [ `expr substr "$line_by_line" 26 12` == "UA ITEM FROM" ]
Reply With Quote
  #3  
Old 10-03-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
you can also use this

Code:
if [[ `expr substr "$line_by_line" 1 13` == "0000000000000"  ||   `expr substr "$line_by_line" 26 12` == "UA ITEM FROM" ]]
-o and -a options are used within single test brackets

&& and || are used withing double brackets
Reply With Quote
  #4  
Old 10-03-2006
Registered User
 

Join Date: Aug 2006
Posts: 45
Thanks Anubh ...it works...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0