Case (ksh)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Case (ksh)
# 1  
Old 12-11-2003
Case (ksh)

Isn't any "NOT" operator that can be used in the case construction like :

case $VAR (NOT) in
option1 | option2 | option 3...) COMMAND ;;
esac


Or something similiar to the "default" from switch, so I could at least do something like this:

case $VAR in

option 1 | option 2 | option 3 ...) do nothing ;;
default) COMMAND ;;

If the answer is no,
Smilie
I'll use a flag that is filled when VAR is one of the possible values...
# 2  
Old 12-11-2003
* can be the default

Code:
case $VAR in
     pattern1)
          statement 1
          ;;
     pattern2)
          statement 2
          ;;
       *)
         default statement
          ;;
esac

# 3  
Old 12-11-2003
case ${var} in
!pattern1)
statements
;;
!pattern2)
statements
;;
*)
statements
;;
esac
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh case statement issue

Hi. I wrote the following case statement to replace a series of 'ELIF' statements as it looks better and is easier to maintain. However, for some reason the commands don't fully work in this format. Take option 1. It should call a script that runs in the background but it doesn't work. Can anyone... (3 Replies)
Discussion started by: user052009
3 Replies

2. Shell Programming and Scripting

Ksh: Send a mail in case grep finds something

I want to search a file if it contains special strings and if yes, the records found should be mailed. I can either do it with a temporary file: /usr/bin/grep somestring somefile > /tmp/tempfile && /usr/bin/mail -s "Found something" email@mycomp.com < /tmp/tempfile... or by running the grep... (10 Replies)
Discussion started by: Cochise
10 Replies

3. Shell Programming and Scripting

Use case insensitive variable in ksh shell scripting using sed or awk

I am using a variable called $variable in a pattern search to print from a starting variable to a constant value. the variable search should be case in sensitive. i tired using Ip at the end in the below command. but in ksh it is not working. sed -n "/$variable/,/constant/p" file i also... (11 Replies)
Discussion started by: johnjs
11 Replies

4. Shell Programming and Scripting

Using an array with a case statement in KSH

Hi, I'm really new ro shell scripting (actually any kind of programming) and am pretty sure I'm making a pretty basic error here but I can't for the life of me figure it out. What I'm trying to do is get an array working with a case statement in a KSH script. The code is as follows: ... (3 Replies)
Discussion started by: SReilly
3 Replies

5. Shell Programming and Scripting

lower to upper case in ksh

What is the command to change the contents of a file to UPPER case. Here in this file below you see some characters are Sp, Ch 1200812270046581 22885072800000652 B86860003OLFXXX592123320081227 22885029800000652 B86860003ODL-Sp592123420081227 22885093700000652-B94030001ODL-Ch592123520081227... (4 Replies)
Discussion started by: kshuser
4 Replies

6. UNIX for Dummies Questions & Answers

case statement in UNIX scripting (ksh)

Hi, I have a script like below : #!/bin/ksh echo "Do you want to export all docs ?" read alld echo "Do you want to export template or report only " read temr case && ] #arguments ;; case && ] #arguments ;; case && ] #arguments ;; (4 Replies)
Discussion started by: luna_soleil
4 Replies

7. UNIX for Dummies Questions & Answers

ksh case structure

Hello Experts, I ve been trying to build another shell where I am using the following code. transact="tv5cpc1" case "$transact" in "...cp..") xActType="" ;; "...de..") xActType="sp_dep" ;; "...ep..") xActType="sp_epa" ;; "....v.") ... (4 Replies)
Discussion started by: hkansal
4 Replies

8. Shell Programming and Scripting

ksh case statement

I am trying to write a ksh script using the case statement to select certain directories to remove. The directories that I am looking for are in the following format 2008-10-10. I want to exclude all other files/directories that contain anything other the 4 digit year,a dash, 2 digit month, a... (2 Replies)
Discussion started by: dgilc
2 Replies

9. UNIX for Dummies Questions & Answers

anchoring regex using case and ksh

Outside this process I built a file containing snmp response filtering for hostname, model type and ios version. I want to get a count across the network of those devices running 11.x code, 12.0 mainline, 12.0 T train and above, 12.1 and above and OS levels. This works ok .. but its cheap... (2 Replies)
Discussion started by: popeye
2 Replies

10. Shell Programming and Scripting

ksh case problem

I'm trying to run a ksh script with a case condition to handle parameters. #!/bin/ksh db_start(){ *code } db_shut(){ *code } case "$1" in up) db_start TRNG ;; down) db_shut TRNG ;; *) echo "Usage: $0 { up | down }" (3 Replies)
Discussion started by: digiteck
3 Replies
Login or Register to Ask a Question