Setting options


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting options
# 1  
Old 04-29-2011
Setting options

I have the following code and want to change it

Code:
  set fdrwtag = `echo $f | awk '/drw/'`
  set fsmptag = `echo $f | awk '/smp/'`
  set rgdttag = `echo $f | awk '/rgdt/'`

  if ($fdrwtag != "") set fdrw = 1
  if ($fsmptag != "") set fsmp = 1
  if ($rgdttag != "") set rgdt = 1

I want to check whether I have "drw", "smp" and/or "rgdt".

If I have "drw", I want idrwsmp = 1, if "smp" put idrwsmp = 2, and if "rgdt" exits put irgdt = 1, otherwise irgdt = 0.

---------- Post updated at 08:12 PM ---------- Previous update was at 07:12 PM ----------

Any better way to do the below?

Code:
  set idrw = `echo $f | awk '/drw/ {print 1}; ! /drw/ {print 0}'`
  set ismp = `echo $f | awk '/smp/ {print 1}; ! /smp/ {print 0}'`
  set irgdt = `echo $f | awk '/rgdt/ {print 1}; ! /rgdt/ {print 0}'`

# 2  
Old 04-30-2011
By case statement
Code:
case "$f" in
  *drw*)  idrwsmp=1;
             ;;
  *smp*) idrwsmp=2;
             ;;
  *rgdt*) irgdt=1;
             ;;
  *)        irgdt=0;
             ;;
esac

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Is there a difference between setting a user as nologin and setting it as a role?

Trying to figure out the best method of security for oracle user accounts. In Solaris 10 they are set as regular users but have nologin set forcing the dev's to login as themselves and then su to the oracle users. In Solaris11 we have the option of making it a role because RBAC is enabled but... (1 Reply)
Discussion started by: os2mac
1 Replies

2. Shell Programming and Scripting

jar options..Help..

Hi, Is there an option with jar command which allows us to copy some class files(already existing,want to override)to a jar file without exploding it.? Thanks in advance. (1 Reply)
Discussion started by: dnam9917
1 Replies

3. Ubuntu

Kernel boot options removed by fault, no boot options

Hello Everyone, First of all, I highly appreciate all Linux forum members and whole Linux community. http://forums.linuxmint.com/images/smilies/icon_wink.gif. I wish you the best for all of you ! I will try to be short and concise: I am using Linux Mint 10 for 2 months on 2 ws, and all went... (3 Replies)
Discussion started by: cdt
3 Replies

4. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies

5. UNIX for Dummies Questions & Answers

Firefox: Setting about:config options upon install

Is there a way to set the about:config options for Firefox automatically as part of the installation of Firefox? (3 Replies)
Discussion started by: figaro
3 Replies

6. AIX

no options

Hi All, I have a situation here that's very fun... I have a system with AIX and iPlanet (sunOne) installed, when occurs an unknown event on the network the WebServer shows a thousand of CLOSE_WAIT connections and this number grows and grows until the webserver crashs. I read some documents... (2 Replies)
Discussion started by: nascimento.rp
2 Replies

7. UNIX for Dummies Questions & Answers

options

I am just beginning to learn unix and I was wondering if there was a list of all the options somewhere on the net or hidden in the man pages? Also do options always have - and then a letter, or can it be - and a number as well? Thanks! (1 Reply)
Discussion started by: terms5
1 Replies

8. UNIX for Dummies Questions & Answers

cp options

Hello again, Is there an option for the cp command to overwrite existing files in the destination directory? Cheers Rob (3 Replies)
Discussion started by: milage
3 Replies
Login or Register to Ask a Question