logical expressions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting logical expressions
# 1  
Old 06-03-2009
logical expressions

Hi Fdz,

I have to verify the length of two uids are equals to 11 or not. The conditions is both lengths should be 11.I tried with this logic expr. am unable to get correct results.(Shell script in Unix i need)

if [ $START_USER_ID -eq 11 && $END_USER_ID -eq 11 ]
do
echo"Results"
done


Thanx
# 2  
Old 06-03-2009
Hint:
Code:
$ VAR1=asdf; echo ${#VAR1}
4
$ VAR1=asdf1234; echo ${#VAR1}
8

# 3  
Old 06-03-2009
Code:
if [  ${#START_USER_ID} -eq 11 -a ${#END_USER_ID} -eq 11 ]
then
echo "done"
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Boolean expressions for If's

1. The problem statement, all variables and given/known data: Im experimenting with if expressions for an assignment. What i want to do is check if an input of read x y z will be checked against x for 1-999 for y for and for z for 1-999. Am i doing this right? or perhaps you could tell me... (0 Replies)
Discussion started by: Ren_kun
0 Replies

2. Shell Programming and Scripting

Regular Expressions

Hi Ilove unix and alwyas trying to to learn unix,but i am weak in using regular expressions.can you please give me a littel brief discription that how can i understand them and how to use .your response could lead a great hand in my unix love. (1 Reply)
Discussion started by: manoj attri
1 Replies

3. Shell Programming and Scripting

Regular Expressions

I am new to shell scripts.Can u please help me on this req. test_user = "Arun" if echo "test_user is a word" else echo "test_user is not a word" (1 Reply)
Discussion started by: chandrababu
1 Replies

4. UNIX for Advanced & Expert Users

regular expressions

I have a flat file with the following drug names Nutropin AQ 20mg PEN Cart 2ml Norditropin Cart 15mg/1.5ml I have to extract digits that are before mg i.e 20 and 15 ; how to do this using regular expressions Thanks ram (1 Reply)
Discussion started by: ramky79
1 Replies

5. UNIX for Dummies Questions & Answers

Combining Expressions

Hi there, I'm having some trouble with a script were I want 2 expressions to evaluate to true before my if loop will continue... if ; then Both these expressions work on their own, but not when combined. What am I doing wrong? Regards davewg :) (6 Replies)
Discussion started by: davewg
6 Replies

6. Shell Programming and Scripting

How to do logical AND and logical OR with grep

Hi can someone please help me on this. I need to perform this code: Grep any lines that meets the following criteria (A AND B) OR (A AND C) I tried this code, but it didn't work Grep-I "A &&B" | "A&&C" *.* $ thanks in advance (12 Replies)
Discussion started by: Needhelp2
12 Replies

7. UNIX for Dummies Questions & Answers

regular expressions

how to find for a file whose name has all characters in uppercase after 'project'? I tried this: find . -name 'project**.pdf' ./projectABC.pdf ./projectABC123.pdf I want only ./projectABC.pdf What is the regular expression that correponds to "all characters are capital"? thanks (8 Replies)
Discussion started by: melanie_pfefer
8 Replies

8. UNIX for Dummies Questions & Answers

regular expressions

Hi Gurus, I need help with regular expressions. I want to create a regular expression which will take only alpha-numeric characters for 7 characters long and will throw out an error if longer than that. i tried various combinations but couldn't get it, please help me how to get it guys. ... (2 Replies)
Discussion started by: ragha81
2 Replies

9. Shell Programming and Scripting

Help with regular expressions

I have following content in the file CancelPolicyMultiLingual3=U|PC3|EN RestaurantInfoCode1=U|restID1|1 ..... I am trying to use following matching extression \|(+) to get this PC3|EN restID1|1 Obviously it does not work. Any ideas? (13 Replies)
Discussion started by: arushunter
13 Replies

10. Shell Programming and Scripting

regular expressions

Hi, can anyone advise me how to shorten this: if || ; then I tried but it dosent seem to work, whats the correct way. Cheers (4 Replies)
Discussion started by: jack1981
4 Replies
Login or Register to Ask a Question