Results 1 to 3 of 3
Hi, i was wondering if someone could help me figure out a script for global variables i'm trying to set for a group of command line arguments:
basically i'm trying ...
- 10-11-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 3
bourne script help
Hi, i was wondering if someone could help me figure out a script for global variables i'm trying to set for a group of command line arguments:
basically i'm trying to set:
if $# = 3
then i want to search for each all string $1 $2 $3
if $# = 4
then i want to search for each all string $1 $2 $3 $4
any ideas?
- 10-12-2010 #2Linux User
- Join Date
- Jan 2005
- Location
- Saint Paul, MN
- Posts
- 262
Are you restricted to have it be "Borne Shell" or is "BASH" okay?
What do you mean by search? Is it a grep searching for 3 or 4 patterns?
- 10-12-2010 #3Linux User
- Join Date
- Jan 2005
- Location
- Saint Paul, MN
- Posts
- 262
For example if the need to grep a file for "patterns" in Bourne.
If Bash is okay:Code:case $#; in 3) grep -E "$1|$2|$3" search_on_filename_or_list ;; 4) grep -E "$1|$2|$3|$4" search_on_filename_or_list ;; esac
Code:grep -E "'$(IFS='|' && echo "$*")'" search_on_filename_or_list


Reply With Quote