WHERE statement similar to IDL


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers WHERE statement similar to IDL
# 1  
Old 08-01-2008
WHERE statement similar to IDL

Is there a Unix command similar to the WHERE command in IDL. Such a command would return all location numbers of an array where the value at those locations satisfy specified conditions. For example, if I have a random vector

vector=(3 5 6 9)

how can I find the location numbers in ${vector} corresponding to values less gt 3 and lt 9.

What should be returned is a two-element vector: (1 2)

How can I get Unix to do this?
# 2  
Old 08-02-2008
How do you mean - get UNIX to do this? perl, python, ruby, etc. all can do something like this for you with a small bit of programming, if you want C or shell script you have to roll your own.. We'll help, just let us know what you need.
# 3  
Old 08-02-2008
Hi,

I would like to have this within a bash shell script. This would allow me to get around some scripting trouble that nobody has been able to sufficiently help with yet. I have a directory containing multiple files, all of similar construct:
A2008196231000.L2

I am only interested in digits 6-8, so the filenames are effectively:
?????---* (where the three digits --- represent the year day of the file)

I have files ranging from ?????001* to ?????366*. How can I list all the files within a certain range of days? The fact that the year days must be three digits long (001 to 366) makes this difficult.

If anyone could help with that, it would be great! The reason I would like a WHERE statement would be to get around this. Perhaps I could create an array, where each element is a different filename in the directory. Then I would create another array of the same size, where each element is the three digit year day of the file in the initial array. Then I could find out which elements of this array are -gt or -lt bounds that I specify, and use the returned array locations to subset the initial array. Is that possible in a bash shell script?
# 4  
Old 08-02-2008
One way ........

Output all the files for day 12 through day 40
Code:
start=12
end=40

for ((i=start ; i<=end ; i++))
do
  j=${j}$(printf "%03i,\n" ${i} )
done
j=${j%,}

ls A2008{$j}*.L2 2>/dev/null

# 5  
Old 08-02-2008
Hi,

Thank you very much for the reply! I am very new to Unix.

- Could you explain the statement within the for loop?
- What is the meaning of 2>/dev/null?
- Will this work with 3-digit days (001-365)?

Thanks again. I really appreciate the help.
# 6  
Old 08-03-2008
2> /dev/null means that anything written to stderr by the ls(1) command (typically error messages such as could not find a matching file) is not displayed.

Yes this code works with 3 digit days.
# 7  
Old 08-03-2008
If your condition can be covered by a simple wildcard, use that. For example, the following will match all files between 010 and 029.

Code:
A20080[12][0-9]231000.L2

 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. UNIX for Dummies Questions & Answers

Files into IDL directories

Ok so ive downloaded two files, and i need to save them into a directory that can be read in IDL. Can someone please remind me how to do this, like post the code that i need please? Many thanks (0 Replies)
Discussion started by: Benji.
0 Replies

3. Programming

spectra flux-calibration using IDL

Hi, I am searching the web for documentations with tutorials for spectra flux calibration using IDL, does anyone know anything that can help me? Please help :D ---------- Post updated 07-11-09 at 05:38 AM ---------- Previous update was 07-10-09 at 10:46 AM ---------- Does the question make... (0 Replies)
Discussion started by: cosmologist
0 Replies

4. Shell Programming and Scripting

IDL job doesn't work from crontab

I have made a script to execute an IDL routine with the purpose to plot data on a fixed time. The problem is that when I include this script in the crontab to run it every night, the IDL part doesn't work (the other commands, like getting data from the database, are carried out though). This... (4 Replies)
Discussion started by: SharkM
4 Replies

5. UNIX and Linux Applications

Parsing info from a text file into an IDL procedure

Hi, I hope this is appropriate for this forum. I have a text file (test.txt) that contains information that I would like to parse into an IDL procedure. Each line of the text file is either a number or a string, which will be a variable in my IDL procedure. Therefore I want to read each line... (1 Reply)
Discussion started by: msb65
1 Replies

6. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

7. Linux

'IDL:omg.org/CORBA/TRANSIENT:1.0' exception

Hi, We are working in a Linux client server environment ,where we have the CORBA running to facilitate the client server model.But here some time we are getting the system exception, ID 'IDL:omg.org/CORBA/TRANSIENT:1.0' OMG minor code (2), described as 'No usable profile in IOR.', ... (0 Replies)
Discussion started by: prasanta jena
0 Replies

8. UNIX for Advanced & Expert Users

compiling idl file on unix

hi i need to compile idl files to convert them to classes, on Unix platform. Please tell me how to compile these files & which commands are to be used for this purpose. Thanks & Regards (6 Replies)
Discussion started by: rochitsharma
6 Replies
Login or Register to Ask a Question