![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 !! |
|
|
||||
| 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 02:53 AM |
| assign a command line argument and a unix command to awk variables | sweta_doshi | Shell Programming and Scripting | 0 | 08-08-2008 03:54 AM |
| how to? launch command with string of command line options | TinCanFury | Shell Programming and Scripting | 5 | 04-28-2008 03:06 PM |
| how do i strip this line using perl regex. | ramky79 | Shell Programming and Scripting | 1 | 03-18-2008 09:10 AM |
| 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 05:27 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
since i'm still at the top of the list, i thought i would add that i'm using ksh.
thanks for your help. |
|
#3
|
|||
|
|||
|
Testing a parameter at the command line? Be preciser and clarify what your trying to achieve.
Regards |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
Using getopts would be a better bet imho.
-g group, -u user -r (optional regexp)...that kind of thing. |
|||
| Google The UNIX and Linux Forums |