![]() |
|
|
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 |
| read string, check string length and cut | ozzy80 | Shell Programming and Scripting | 9 | 03-21-2007 05:56 PM |
| replacing a string in a file with command line parameter | chiru_h | Shell Programming and Scripting | 5 | 08-03-2006 10:34 AM |
| Passing a string parameter to a function | fastgoon | Shell Programming and Scripting | 1 | 07-17-2006 03:37 PM |
| Help with making a parameter check script. | GCTEII | Shell Programming and Scripting | 2 | 03-07-2006 03:30 AM |
| How to check parameter variable? | negixx | Shell Programming and Scripting | 4 | 06-10-2005 06:37 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
While case...esac is fine, if you have your heart set on using 'expr' you can use expr this way:
expr $parameter : ".*$search" >/dev/null && echo Found!!! In this form, expr returns the # of characters matched from the beginning of $parameter. That's why I had to put a ".*" in the beginning of the search string. Also, expr writes the number of characters matched to stdout (so I directed to /dev/null). Of course, you can just use this value in a test like this: if [ expr $parameter : ".*$search" -gt 0 ] then |
![]() |
| Bookmarks |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|