LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2013, 10:05 PM   #1
ankitpandey
Member
 
Registered: Jan 2012
Location: Mumbai
Posts: 63

Rep: Reputation: Disabled
Multiple condition in case command for one feild


Hello All,

Is it possible to enter multiple option in one feild for which same action is needed ?

If you see below code, i have three state a, b and c for which i need same set of command execution. So is it possible to enter them in same feild ? Please suggest.

Code:
while read state; do

    case $state in

        X)        <commands for this match> ;;
        Y)       <commands for this match> ;;
        a, b, c) <commands for this match> ;;
        d)     <commands for this match> ;;

    esac

done <inputfile.txt
 
Old 03-07-2013, 10:13 PM   #2
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
Logically OR the case options:
Code:
case $state in
  a|b|c) <commands for this match> ;;
esac
Hope it helps.

Last edited by towheedm; 03-08-2013 at 06:28 AM.
 
1 members found this post helpful.
Old 03-07-2013, 11:59 PM   #3
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
It depends on the programming language.
 
Old 03-08-2013, 01:02 AM   #4
ankitpandey
Member
 
Registered: Jan 2012
Location: Mumbai
Posts: 63

Original Poster
Rep: Reputation: Disabled
Thanks towheedm
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
use case condition in the script dnaqvi Programming 11 05-21-2010 05:36 PM
bash case statement with multiple command line options pwc101 Programming 16 06-01-2007 11:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration