The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2008
ankimo ankimo is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 23
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
thanks for your help.
  #2 (permalink)  
Old 10-08-2008
ankimo ankimo is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 23
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 (permalink)  
Old 10-08-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,291
Testing a parameter at the command line? Be preciser and clarify what your trying to achieve.

Regards
  #4 (permalink)  
Old 10-08-2008
ankimo ankimo is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 23
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
here's as far as i got.. and i admit, it's not far....


Code:
if [ "$*" begins with any of these '[][\\.*$^]/\\&' ]
  ./script2 regex
else
  do something else
fi
thanks
  #5 (permalink)  
Old 10-08-2008
ramen_noodle ramen_noodle is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2007
Location: Virginia, USA.
Posts: 251
Using getopts would be a better bet imho.
-g group, -u user -r (optional regexp)...that kind of thing.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0