![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
try this
Code:
if [ `expr substr "$line_by_line" 1 13` == "0000000000000" -o `expr substr "$line_by_line" 26 12` == "UA ITEM FROM" ] Code:
if [ `expr substr "$line_by_line" 1 13` == "0000000000000" ] || [ `expr substr "$line_by_line" 26 12` == "UA ITEM FROM" ] |
|
#3
|
|||
|
|||
|
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" ]] && and || are used withing double brackets |
|
#4
|
|||
|
|||
|
Thanks Anubh ...it works...
|
|||
| Google The UNIX and Linux Forums |