![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Converting integer to String | ROOZ | Shell Programming and Scripting | 1 | 06-05-2008 02:38 PM |
| Checking if string contains integer | haz | Shell Programming and Scripting | 7 | 09-11-2006 03:51 AM |
| conersting string to integer | abb058 | UNIX for Dummies Questions & Answers | 2 | 08-23-2006 08:52 AM |
| Integer to String | psilva | High Level Programming | 2 | 08-17-2001 01:14 PM |
| convert from an integer to a string | mojomonkeyhelper | UNIX for Dummies Questions & Answers | 6 | 03-29-2001 05:15 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Comparing string and integer in IF
hi,
I need to create an IF condition. I read a line from a file and get the 5 word using space as a delimited. This word can have only two values either '*' or '1-5' I need to write an IF condition for two cases. I can either compare it to * or 1-5(or even 1 by cutting and getting only the first character). But when I write it eg, if [$var -eq '*' ] If the value is 1-5 it says integer argument expected. If I write if [ $var == 1 ] In this case when the value is '*' it says string expected. How can I resolve this. Cannt I declare that the $var is always goiing to be a char. So I can use -eq '*' and -eq '1-5'. |
![]() |
| Bookmarks |
| Tags |
| conditionals, string vs integer |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|