![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| bash - delay expansion of variable | scandora | Shell Programming and Scripting | 3 | 02-18-2009 05:59 AM |
| globbing, $# is too high after wildcard expansion in bash script | zoo591 | Shell Programming and Scripting | 3 | 07-25-2008 03:50 AM |
| Pattern expansion problem | njoshi | Shell Programming and Scripting | 5 | 04-24-2007 01:28 PM |
| AIX Expansion CD | almuwatta | AIX | 0 | 06-23-2005 06:07 PM |
| ksh on HP-UX -- variable expansion | dangral | UNIX for Dummies Questions & Answers | 4 | 02-08-2005 12:35 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Brace expansion problem in Bash
I have a script that takes an option for server pools to run the script against. The option is given as a comma separated list (ie, -p 201,204,301).
I'm using eval and brace expansion to get those pool numbers into an array. It works fine unless only 1 pool number is given. Here's the code: Code:
while [ "$1" != "" ]; do
case $1 in
-p ) shift
pools=($(for i in $(eval echo {$1}); do echo $i; done | sort))
;;
Code:
[me@server bin]$ ./project_nunenhoffen.sh -p 201,202
+ '[' -p '!=' '' ']'
+ case $1 in
+ shift
+ pools=($(for i in $(eval echo {$1}); do echo $i; done | sort))
++ sort
+++ eval echo '{201,202}'
++++ echo 201 202
++ for i in '$(eval echo {$1})'
++ echo 201
++ for i in '$(eval echo {$1})'
++ echo 202
+ shift
+ '[' '' '!=' '' ']'
Code:
[me@server bin]$ ./project_nunenhoffen.sh -p 201
+ '[' -p '!=' '' ']'
+ case $1 in
+ shift
+ pools=($(for i in $(eval echo {$1}); do echo $i; done | sort))
++ sort
+++ eval echo '{201}'
++++ echo '{201}'
++ for i in '$(eval echo {$1})'
++ echo '{201}'
+ shift
+ '[' '' '!=' '' ']'
Thanks, Mike G. |
|
||||
|
Quote:
For now I've solved my problem this way: Code:
while [ "$1" != "" ]; do
case $1 in
-p ) shift
case $1 in
*,* ) pools=( $(for i in $(eval echo {$1}); do echo $i; done | sort) ) ;;
* ) pools=$1 ;;
esac
;;
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|