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 > Shell Programming and Scripting
.
google unix.com



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 preferred or ksh with bash features mrwatkin UNIX for Dummies Questions & Answers 2 06-17-2009 02:19 PM
how to make your bash script run on a machine with csh and bash npatwardhan Shell Programming and Scripting 3 11-19-2008 04:17 AM
bash and ksh: variable lost in loop in bash? estienne Shell Programming and Scripting 2 08-25-2008 03:09 PM
passing variable from bash to perl from bash script arsidh Shell Programming and Scripting 10 06-04-2008 01:25 PM
Why generate "ash and bash" different output for same bash script? s. murat Shell Programming and Scripting 0 05-26-2008 08:19 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-25-2009
talashil talashil is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 61
Bash Help

I have ksh script and converting to bash . This portion is failing .

code in ksh:

Code:
read choice
        until [[ $tries -gt 2 || $choice = +([0-9]) && $choice -gt 0 \
                && choice -le "${#rdbms[*]}" ]]; do
                print -n "Invalid choice - must enter number between 1"
                print -n " and ${#rdbms[*]}: "
                read choice
                let tries=tries+1
        done
and when I run this under bash shell , it's giving the error as :

Code:
line 235: syntax error in conditional expression: unexpected token `('
line 235: syntax error near `+(['
line 235: `        until [[ $tries -gt 2 || $choice = +([0-9]) && $choice -gt 0 \'
any help with this ...

Thanks

Last edited by vgersh99; 08-25-2009 at 02:06 PM.. Reason: code tags, PLEASE!
Bits Awarded / Charged to talashil for this Post
Date User Comment Amount
08-25-2009 vgersh99 added code tags - charged 3K bits -3,000
  #2 (permalink)  
Old 08-25-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
  #3 (permalink)  
Old 08-25-2009
laurentv laurentv is offline
Registered User
  
 

Join Date: Mar 2009
Location: Montreal, Canada
Posts: 33
remove "(" and ")" in "+([0-9])"
also you might want to replace print command by echo
  #4 (permalink)  
Old 08-26-2009
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 711
Hi.
I suggest experimenting with bash builtin shopt:
Code:
       If the extglob shell option is enabled using the shopt builtin, several
       extended pattern matching operators are recognized.  In  the  following
       description, a pattern-list is a list of one or more patterns separated
       by a |.  Composite patterns may be formed using one or more of the fol-
       lowing sub-patterns:

              ?(pattern-list)
                     Matches zero or one occurrence of the given patterns
              *(pattern-list)
                     Matches zero or more occurrences of the given patterns
              +(pattern-list)
                     Matches one or more occurrences of the given patterns

-- excerpt from man bash
cheers, drl
  #5 (permalink)  
Old 08-26-2009
talashil talashil is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 61
Thankyou Guys.
Reply

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 10:01 PM.


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