![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| quoting in conditional statement | 3Gmobile | Shell Programming and Scripting | 2 | 08-14-2006 03:14 AM |
| *.pm globs without quoting, *.pl doesn't. | tphyahoo | Shell Programming and Scripting | 2 | 06-02-2006 11:37 AM |
| M4 quoting drives me crazy | hindman | Shell Programming and Scripting | 0 | 05-26-2006 10:30 AM |
| Quoting of special characters | vibhor_agarwali | UNIX for Dummies Questions & Answers | 1 | 01-30-2005 04:58 AM |
| quoting echo 'it's friday' | yls177 | UNIX for Dummies Questions & Answers | 3 | 09-19-2002 11:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Wildcards and quoting
Hi All
In a script, I want a user to enter 4 characters, these can be a mix of letters (uppercase and lowercase) and numbers. In this example $var represents what the user has entered. eg $var can be A9xZ, 3DDL, bbHp .........etc I need to check that the user has only entered characters so I added the following code: # Check for invalid characters echo "$var" | grep [^a-zA-Z0-9] >/dev/null if [ $? -eq 0 ] then echo "$var is not valid." fi This appears to work ok unless the user enters a wildcard character. For example if the user enters bin*, the script expands the * and makes $var equal to all files in the current directory which start with bin. So $var is "bin bindir binary" My question is how can I process $var literally as "bin*" in the above grep statement? Thanks for your help Helen ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|