Problem using bash case statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem using bash case statement
# 1  
Old 03-20-2012
Problem using bash case statement

I have the following bash script and it is not accepting the lines

Code:
  "--"[sS][rR][cC][sS][iI][fF]|"--"[sS][rR][cC][sS]"-"[iI][nN][fF][iI][lL][eE])
  "--"[sS][oO][uU][rR][cC][eE][sS]"-"[iI][nN][fF][iI][lL][eE]")


Code:
while [ "$#" -gt 0 ]
do

  echo "Current Argument is ${1}"
  case "$1" in

  "--"[cC][mM][oO][dD][iI][fF]|"--"[cC][mM][oO][dD]"-"[iI][nN][fF][iI][lL][eE])
    echo "Argument is ${1}"
    shift     # Skip ahead one to the next argument.
    arg_cmodInFile="${1}"
  ;;

  "--"[sS][rR][cC][sS][iI][fF]|"--"[sS][rR][cC][sS]"-"[iI][nN][fF][iI][lL][eE])
  "--"[sS][oO][uU][rR][cC][eE][sS]"-"[iI][nN][fF][iI][lL][eE]")
    shift     # Skip ahead one to the next argument.
    arg_srcsInFile="${1}"
    opt_srcsInFile=1
  ;;

  esac

  shift # Skip ahead to the next argument

done

# 2  
Old 03-20-2012
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash read input in case statement not working as expected

I'm having an issue with bash read input when using a case statement. The script halts and doesn't read the input on the first loop. if I hit enter then the scripts starts to respond as expected. Need some help here. defaultans=8hrs read -e -i $defaultans -p "${bldwht}How long would you like... (5 Replies)
Discussion started by: woodson2
5 Replies

2. Shell Programming and Scripting

BASH - case statement

Hi Gurus, I have the below BASH code which does not works for upper case alphabets except Z (upper case Z). What may be the reason. Also escape sequences like \n, \t, \b, \033(1m \033(0m (For bold letter) are not working. case $var in ) echo "Lower case alphabet" ;; ... (7 Replies)
Discussion started by: GaneshAnanth
7 Replies

3. Shell Programming and Scripting

Bash case Statement and Using Line Anchors?

Hello All, I am writing a script that is to be placed on multiple servers, and of course I've started running into some compatibility issues for certain shell commands. The code below worked just fine on most of my machines except for a couple. Here I had 4 separate lines in my script that... (3 Replies)
Discussion started by: mrm5102
3 Replies

4. Shell Programming and Scripting

Can you use logical operators in a case statement (bash)?

I'm pretty sure I already know the answer to this, but I want to make sure I'm not overlooking anything. I'm working on a log monitoring script and every 10 lines I want to display a summary of events. The thing is, there are a lot of possible events, that likely won't have happened, so I only want... (0 Replies)
Discussion started by: DeCoTwc
0 Replies

5. Shell Programming and Scripting

Problem using 'Case' statement

Hi, When I execute the below script, I am getting the error as ' is not expected.ror at line 3 : `in #!/bin/sh case $1 in -r) echo Force deletion without confirmation ;; -i) echo Confirm before deleting ;; *) echo Unknown argument ;; esac I could not see any problem with... (1 Reply)
Discussion started by: Sathish_Obla
1 Replies

6. Shell Programming and Scripting

Problem with CASE statement

Guys, Here is the script syntax which is not accepting the parameters & not performing the said activity. $ ./routing.sh xyz123-ra str enable ********************************************************************** Preparing to service the request for Device xyz123-ra in Question... (9 Replies)
Discussion started by: raghunsi
9 Replies

7. Shell Programming and Scripting

bash case statement output help

greetings, I have a script that is taking input like this: a b c d aa bb aaa bbb ccc ddd and formating it to be like this: a b c d aa bb aaa bbb ccc ddd (4 Replies)
Discussion started by: adambot
4 Replies

8. Shell Programming and Scripting

Problem with case statement

Hi, I need modify the all lines in a file into one format. cat file htec.twe34c.ATI .hesh.twdghu..ATI ..hesh.twdghu..ATI htec.twe3 hjsct14567ati Output should have 16 characters htectwe34c ATI heshtwdghu ATI heshtwdghu ATI htectwe3 ATI hjsct14567 ATI (4 Replies)
Discussion started by: kartheek
4 Replies

9. Shell Programming and Scripting

[BASH] recognise new line regex in case statement

Hi, I'm trying to write a routine to parse a file that contains data that will be read into arrays. The file is composed of labels to identify data types and arbitrary lines of data with the usual remarks and empty new lines as is common with config files. The initial pass is built as so:... (3 Replies)
Discussion started by: ASGR
3 Replies

10. UNIX for Advanced & Expert Users

Case statement problem

I need to display this menu and accept variables. Can someone tell me why i am having a problem with this case statement, please # TAPE MANAGER MAIN MENU tapemgr_Main_Menu() { echo "Legato Tape Management System Menu" echo " This system is used to report Legato ERV Offsite and Tapes... (6 Replies)
Discussion started by: gzs553
6 Replies
Login or Register to Ask a Question