![]() |
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 |
| sed: delete regex line and next line if blank | one71 | Shell Programming and Scripting | 2 | 09-18-2008 05:53 AM |
| assign a command line argument and a unix command to awk variables | sweta_doshi | Shell Programming and Scripting | 0 | 08-08-2008 06:54 AM |
| how to? launch command with string of command line options | TinCanFury | Shell Programming and Scripting | 5 | 04-28-2008 06:06 PM |
| how do i strip this line using perl regex. | ramky79 | Shell Programming and Scripting | 1 | 03-18-2008 12:10 PM |
| Regex to pick up name from the following including carriage return at end of the line | Shakey21 | Shell Programming and Scripting | 3 | 07-18-2002 08:27 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
testing for regex at command line
hi unixers,
i wonder if someone can tell me how i can check for a regex at the command line? Code:
if any parameter begins with a special character then do this else do that |
|
||||
|
sorry about that and thanks for your response Franklin52.
i have a script that has this syntax: script <group_id> <user_name> <regex> rules: * the user can enter single or multiple group_ids and/or user_names * the regex is optional * group_ids are 5-digit integers * user_names are can be a combo of chars and integers because the regex parameter is optional, i want to check if it was added at the command line. further, if the regex was actually added, then i want to use that regex value against a different script that i created: Code:
if any parameter begins with a special character; then run a different script with the regex parameter else do something else fi Code:
if [ "$*" begins with any of these '[][\\.*$^]/\\&' ] ./script2 regex else do something else fi |
|
||||
|
Using getopts would be a better bet imho.
-g group, -u user -r (optional regexp)...that kind of thing. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|