Using arrays with the IF conditional

What Im trying to do is test the value of an variable and see if it exists inside an array. So as a simple example I would do something like this with AppleScript
set excludeList to {"A", "B"}
set theItem to "C"
if theItem is not in excludeList then
display dialog theItem
end if
So how would I replicate that in a shell script. Currently I would just use a long if statement like this
#!/bin/sh
theItem="C"
if [ $theItem != "A" ] && [ $theItem != "B" ]
then
echo $theItem
fi
But I feel there has to be a better way. I suppose I could put the if in a loop and go through the array, but I'm wondering if there is a route more similar to my basic applescript example.
Thanks!
Message was edited by: James Nierodzik because I can't type

A little follow up: If anyone's using the script I referred to above, I've tweaked the style to override line height and simulate an 80 column display. So the above now looks like:
<pre style="padding-left: .75ex; padding-top: .25em; padding-bottom: .25em; margin-top: .5em; margin-bottom: .5em; margin-left: 1ex; max-width: 80ex; overflow: auto; font-size: 9px; font-family: Monaco, 'Courier New', Courier, monospace; color: #222; background: #ddd; line-height: normal">#!/bin/sh
theItem="C"
if [ $theItem != "A" ] && [ $theItem != "B" ]
then
echo $theItem
fi</pre>
Cole

Similar Messages

  • Synchronis​e time in array with the real time from computer

    i need help in syrnchonising my array and the real time running in my computer
    As stated in the text file attached,
    12:32:30 AM 0.38 1.14
    2nd column is wind speed, 3rd is gust speed.
    i would like to display the wind speed in a gauge with the right values. like for example, at 12:32:30 AM OF REAL TIME, NOT BASED ON THE TEXT, i would like to display the 0.38m's of wind speed in the gauge.
    how do i sync the time in array with the real-time?
    i have attached a program i made so far. its abit messy. im still a student, need a lil help
    Attachments:
    Wind Speed and Gust Speed.txt ‏13 KB
    Time and MaxMin.vi ‏18 KB

    wali123 wrote:
    wat u mean duplicate?
    Don't continually post the same question over and over. If you have new information, add it to the original thread. Did you actually click the link under the word "duplicate"?
    Chopping up a discussion about the same thing into several threads (like here is this thread, but also here and here) serves no useful purpose. It will not increase the chance of a good answer, in fact most people will simply ignore it.
    Imagine if everybody else would post like you! Every discussion would be if three different places and we would have three times more threads.
    LabVIEW Champion . Do more with less code and in less time .

  • Is there a way to Configure "Silent Monitoring" in CUCM with the following conditions: ?

    Is there a way to Configure "Silent Monitoring" in CUCM with the following conditions: ?
    -no UCCX platform
    -cisco phone is CP-6941.
    I have read some cisco docs pertaining to Barge and cBarge, however i see that as one-to-one arrangement.
    Is there a way to configure in cucm, something like an ad-hoc conference wherein the Observer will
    just call the extension number to be observed?
    or something like "service observed" feature in Avaya wherein the Observer will dial a particular
    passcode followed by the extension # of the agent, then he is able to observe the on-going call.

    You can do continous recording using SPAN ports or DMS with 3rd party products like Verint Impact 360.
    not sure about the legalities around that though.
    =============================
    Please remember to rate useful posts, by clicking on the stars below.
    =============================

  • I purchased songs from 2 different computers using itunes with the same apple id. I had 1 iPod I used for these but I just recently got an iPhone and I was wondering why it wasn't letting me put my purchased songs on my iPhone?

    I purchased songs from 2 different computers using itunes with the same apple id. I had 1 iPod I used for these but I just recently got an iPhone and I was wondering why it wasn't letting me put my purchased songs on my iPhone?

    You can transfer iTunes content from an iTunes library on a single computer only.
    Since these songs were purchased with the same iTunes account, you can download the song that is not in your iTunes library on the computer you will be syncing your iPhone with. Or you can download the song or songs direct on your iPhone.
    http://support.apple.com/kb/HT2519?viewlocale=en_US&locale=en_US

  • Is there any way to an index that can be used to include the "OR condition "?

    Hello I have some questions.
    The test was conducted in the following procedure .
    create table test
    c1 varchar2(10),
    c2 varchar2(10),
    primary key(c1)
    create index test_idx1 on test(c2);
    Command> explain select * from test where c1 = 'AAAAAAAAAA' or c2 = 'AAAAAAAAAA';
    Query Optimizer Plan:
      STEP:                1
      LEVEL:               1
      OPERATION:           RowLkRangeScan
      TBLNAME:             TEST
      IXNAME:              TEST
      INDEXED CONDITION:   <NULL>
      NOT INDEXED:         TEST.C2 = 'AAAAAAAAAA' OR TEST.C1 = 'AAAAAAAAAA'
    Command>
    Command> explain select * from test where c1 = 'AAAAAAAAAA' and c2 = 'AAAAAAAAAA'
    Query Optimizer Plan:
      STEP:                1
      LEVEL:               1
      OPERATION:           RowLkRangeScan
      TBLNAME:             TEST
      IXNAME:              TEST
      INDEXED CONDITION:   TEST.C1 = 'AAAAAAAAAA'
      NOT INDEXED:         TEST.C2 = 'AAAAAAAAAA'
    Command>
    By including the "OR condition " in this test does not use the index.
    Is there any way to an index that can be used to include the "OR condition "?
    Thanks.
    GooGyum.

    A database cannot in general use indexes in this way for an 'or' involving two different columns. However, for this specific example one can easily rewrite the query using 'UNION' to use the relevant indexes while still giving the same (correct) result:
    Command> explain select * from test t1 where t1.c1 = 'AAAAAAAAAA' union select * from test t2 where t2.c2 = 'AAAAAAAAAA';
    Query Optimizer Plan:
      STEP:                1
      LEVEL:               1
      OPERATION:           RowLkRangeScan
      TBLNAME:             TEST
      IXNAME:              TEST
      INDEXED CONDITION:   T1.C1 = 'AAAAAAAAAA'
      NOT INDEXED:         <NULL>
      STEP:                2
      LEVEL:               2
      OPERATION:           RowLkRangeScan
      TBLNAME:             TEST
      IXNAME:              TEST_IDX2
      INDEXED CONDITION:   T2.C2 = 'AAAAAAAAAA'
      NOT INDEXED:         <NULL>
      STEP:                3
      LEVEL:               1
      OPERATION:           OrderBy
      TBLNAME:             <NULL>
      IXNAME:              <NULL>
      INDEXED CONDITION:   <NULL>
      NOT INDEXED:         <NULL>
      STEP:                4
      LEVEL:               2
      OPERATION:           UnionMergeSort
      TBLNAME:             <NULL>
      IXNAME:              <NULL>
      INDEXED CONDITION:   <NULL>
      NOT INDEXED:         <NULL>
    Maybe you can apply a similar trick? If you know there is no possibility of duplicate rows then you can further optimise this (in terms of performance) by using UNION ALL.
    Chris

  • Can I purchase an iphone3g and then use it with the apple golf app as a golf gps without having to be on a cell plan or data plan?

    If I purchase an iPhone 3g, can I then use it with the apple golf app without having cell or data service?

    You do not need have cell service for the GPS to work.
    If the iphone is new, then you would have to activate it with a carrier in order for it to work at all.
    If it is used, then you can use it without wireless service:
    Using an iPhone without a wireless service plan

  • I'm using mac with the newest operating system (snow leopard 10.6.7). since I've updated to Firefox 4 It doesn't display Hebrew fonts- I didn't have any problems with it before the upgrade and in safari I don't have this problem.

    Hello, I'm using Mac with the newest operating system (snow leopard 10.6.7). since I've updated to Firefox 4 It doesn't display Hebrew fonts… I didn't have any problems with it before the upgrade and in safari I have no problem with it. please help me- I don't like to use safari a my browser...

    elly903 wrote:
    Before commenting - I CANNOT install Mavericks because it'll mess up the versions of Filemaker Pro and Quicken that I use regularly...
    Quicken 2007 for Intel (Snow Leopard, Lion, Mt. Lion and Mavericks) for $15:
    http://quicken.intuit.com/personal-finance-software/quicken-2007-osx-lion.jsp
    It will input your Quicken PPC data file directly if it was Quicken 2005 through 2007.  If older you need Quicken 2006 or 2007 PPC first to convert your data file; and this update must be done BEFORE you upgrade to Mavericks:
    http://quicken.intuit.com/support/help/patching/quicken-2006-manual-updates--mac -/GEN82200.html
    Filemaker Pro PPC (in this case 7) running in Snow Leopard Server installed into Parallels for use in Lion, Mt. Lion and Mavericks:
                                  [click on image to enlarge]
    Snow Leopard Server: 1.800.MYAPPLE (1.800.692.7753) - Apple Part Number: MC588Z/A (telephone orders only)
    This solution allows you to run your Photoshop Elements in Mavericks concurrently with Filemaker Pro PPC.  Mavericks is a free download.

  • I have purchased a eos 6d. When I use it with the iPhone app the connection dies after about five m

    I have a 6d and when I use it with the iPhone app the camera turns off after about five minutes and the connection is lost. So when I am photographing wild life I keep having to break cover to reactivate the connection. Is this correct or is there a way to keep the connection alive.

    You just need to go into the menu and set the camera's sleep mode to "off" or "never". It sounds as if it's currently set to 5 minutes.
    Letting the camera sit active continuously, i.e. preventing it from going into sleep mode, will drain the battery(ies) a lot faster. I don't have a 6D, nor do I leave them on full time (in fact I set sleep mode to a very short duration, since tapping any button on the camera quickly re-awakens it).... so I really don't know how quickly a battery will drain. But you might be prepared with spares. If battery life is too short for you purposes, you could add a battery grip which will double the battery capacity.
    Alan Myers
    San Jose, Calif., USA
    "Walk softly and carry a big lens."
    GEAR: 5DII, 7D(x2), 50D(x3), some other cameras, various lenses & accessories
    FLICKR & PRINTROOM 

  • I use lightroom with the soft proofing feature for my printing. I used to make a copy proof, but all of the sudden something changed, and even if I'm on the copy in the developing mode it prints the original. Also, If i chose a file that was already in li

    I use lightroom with the soft proofing feature for my printing. I used to make a copy proof, but all of the sudden something changed, and even if I'm on the copy in the developing mode it prints the original. Also, If i chose a file that was already in light room to print, even though I have the chosen file up in the developing mode, it will instead print the most recent file that I added to lightroom. If found a way to work around these problems, (check make this the copy in the soft proofing, and copy my settings and delete and reload the old files) but it's a slight hassle and it didn't use to do this. Not sure why it changed. Could I have accidentally changed a setting?

    See
    iOS: Device not recognized in iTunes for Windows
    - I would start with
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    or              
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    However, after your remove the Apple software components also remove the iCloud Control Panel via Windows Programs and Features app in the Window Control Panel. Then reinstall all the Apple software components
    - Then do the other actions of:
    iOS: Device not recognized in iTunes for Windows
    paying special attention to item #5
    - New cable and different USB port
    - Run this and see if the results help with determine the cause
    iTunes for Windows: Device Sync Tests
    Also see:
    iPod not recognised by windows iTunes
    Troubleshooting issues with iTunes for Windows updates
    - Try on another computer to help determine if computer or iPod problem

  • How to use labview with the handyboard

    Hi,
    how to use labview with the handyboard
    Thx...

    I'm assuming you're talking about this, since you didn't provide a link for those of us who don't know what you're talking about.
    As the other poster said, you didn't say how you want to use LabVIEW with it.  If you want to write LabVIEW programs than run on the microprocessor, then you're out of luck.  If you want LabVIEW to interact with it, then you've got a couple of options, SPI probably being the best, but it also has DI and AI that you could use to communicate with it - the DI's could be used as a parallel interface.
    Message Edited by Matthew Kelton on 12-17-2007 02:21 PM

  • Passing values to an internal table and use it with the table painter

    Hi,
    I have seen this topic here before but the answers didn't help me. Maybe I,m doing something wrong.
    The problem is that I defined the following structure on the |Types| tab of the |Global Definitions| section:
    TYPES: BEGIN OF DETAILS,
           EBELP  TYPE EKPO-EBELP,
           BSMNG  TYPE EBAN-BSMNG,
           LFDAT  TYPE RM06P-LFDAT,
    END OF DETAILS.
    Then defined the following definition on the |Global Data| section:
    WA_DETAILS TYPE STANDARD TABLE OF DETAILS WITH HEADER LINE
    The problem is that when I try to assign a value to one of the fields in the program code like this:
    LOOP AT WA_EKPO.
         WA_DETAILS-EBELP = WA_EKPO-EBELP.
         WA_DETAILS-EMATN = WA_EKPO-EMATN.
         MODIFY WA_DETAILS.
    ENDLOOP.
    gives me the following error:
    "WA_DETAILS" is not an internal table -the "OCCURS n" specification is missing.
    Then if I add the "OCCURS 10" to the definition of the Global Data the error "OCCURS 10" is not expected.
    How can I define, assign values and use as a parameter an internal table defined with types for use it with the table painter?

    Hi,
    if it is one record in wa_details. you can directly write as follows..
    REPORT  ZCR_TEST1                               .
    TYPES: BEGIN OF details,
              ebelp TYPE ekpo-ebelp,
              bsmng TYPE eban-bsmng,
              lfdat TYPE rm06p-lfdat,
              ematn TYPE ekpo-ematn,
           END OF details.
    DATA: wa_details TYPE STANDARD TABLE OF details WITH HEADER LINE,
          wa_ekpo    TYPE STANDARD TABLE OF details WITH HEADER LINE.
    wa_details-ebelp = '1'.
    append wa_details.
    wa_ekpo-ebelp = '3'.
    append wa_ekpo.
    LOOP AT wa_ekpo.
      wa_ekpo-ebelp = wa_details-ebelp.
      wa_ekpo-ematn = wa_details-ematn.
      modify wa_ekpo.
    endloop.
    Normally it wont be one record, so u need to put <b>read statement with key</b> in LOOP and ENDLOOP.
    Regards,
    Sriram

  • Can you use IMAP with the ipads mail feature?

    Can you use IMAP with the ipads mail feature?

    Kappy,
    Yes, our domain and email accounts are on a server that does accept IMAP. Also, our mac mini and imacs are all set up for IMAP. Buying an ipad will enable me to work from home during this winter.
    Another ?: do you know if you can use text edit with the iPads mail feature? Reason being we have about 100 generic emails that all we have to do is change a few fields before sending out. Can this be integrated in without having to recreate all these messages?
    -TIM

  • ABAP interfaces build using BDC and BAPIs can be used/replaced with the XI?

    Hi,
      We have develeloped our interfases using BDC and BAPIs. Now our client has decited to implement XI. Now could you please help in finding whether these interfaces can be used/replaced with the XI.
          If yes, please let us know how?
    Thanks and Regards,
    Shweta

    Singh,
    Check this threads where they have discussed on how to use them with XI:
    import BAPI into XI
    Re: interface of xi with bapi
    Re: BDC
    Regards,
    ---Satish

  • Is it possible to create a 1 D array with the "build array VI"? when receiving random number

    Hello all,
    Is it possible to create a 1 D array with the "build array VI" when receiving random number?
    I am receiving random data and the build array VI always create a 2D array which might cause some problem if you want to compute certain type of operation after.
    Any example will be welcomed.
    Thank you,
    Israel 

    Hello Lynn and Yamaeda
    First I want to Thank you Lynn for your linguistic contribution indeed "Build Array" is a primitive and not VI, thank you for the education. In reality what I am doing is simple.
    I have two arrays of complex elements Array1 and Array2.
    Array1 conains the complex elements ""(a0+ib0) ; (a1+ib1) ;...(an+ibn) ;
    Array2 conains the complex elements ""(c0+id0) ; (c1+id1) ;...(cn+idn) 
    What I want to do is the multiplication of the first array by the  conjugate of the second array element.
    Array1*(Conjugate Array 2)" for the first element the results is "(a0.C0-b0.d0) + i(b0c0-a0d0)" and the etc...
    and then taking the square root ([(a0.C0-b0.d0) power of 2]) +  [(b0c0-a0d0) power of 2])
    I was wondering if there were some dedicate primitive that could solve the computation above which is the cross correlation in Frequency domain.
    Thank you very much.
    Israel

  • HT2731 I am using ipad2 with the latest version. While trying to make a apple Id, In the payment information  cannot get the option of "none" what will I do. Please help.

    I am using ipad2 with the latest version. While trying to make a apple Id, In the payment information  cannot get the option of "none" what will I do. Please help.

    You are following the instructions on this page for creating a new account : http://support.apple.com/kb/HT2534 e.g. selecting a free app in the store and tapping on 'create Apple id' when 'buying' the app ? I've just tried it and it works for me

Maybe you are looking for