Welcome to iraf.net Wednesday, May 01 2024 @ 08:31 PM GMT
AndrewS |
06/10/2011 09:41AM (Read 2063 times)
|
|
|
Status: offline
Registered: 10/10/2010
Posts: 33
|
I have been given a selection of fit files that are grouped into directories by type and date and so on, here is generic example of how the structure of directories is organised:maindir-dateofobs-imagetype-objectwhat I want to do is get rid of most of these subdirectories except for the dateofobs as it is convenient to have fit files grouped into seperate directories by that criterion. so in order to keep the date directories I want something like the following (I have not included correct syntax):ls maindir > uniquedate.txt
list=uniqedate
while (list,s1!=){
ls maindir/s1/* | match fit > fitfiles.txt
ls maindir/s1/*/* | match fit > fitfiles.txt
ls maindir/s1/*/*/* | match fit > fitfiles.txt
......and so on until the lowest subdirectory is reached
ls maindir/s1/............./* | match fit > fitfiles.txt}What I can't figure out is the correct syntax for the: ls maindir/s1/* | match fit > fitfiles.txt that is to say that I don't know how to get the string s1 to be recognised as a string variable...I have tried enclosing it in brackets and so on but keep getting feedback such as:** Syntax error
**: ls ../RAW/'(s1)'/*/* | match fit >> allinfo.txtWhat would be the correct syntax here?
|
|
|
|
fitz |
06/10/2011 09:41AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
There are several issues here: combining literal strings with script variables, use of "foreign" commands, and general unix tools. In the CL you would use the '//' operator to concatenate strings and variables, e.g.[code]"ls maindir/" // s1 // "/*/*/* > out.txt"[code]would take the value in the 's1' variable and construct the path string. Typically this is done using the "program mode" syntax, for example[code]print ("!ls maindir/" // s1 // "/*/*/* > out.txt") | cl()[/code]would construct the string and then pipe it to the cl() for execution (note the '!' to escape to a shell command). The IRAF equivalent of 'ls' is the DIR command, so this could also be written as[code]dir ("maindir/" // s1 // "/.....") | match ("fit", "STDIN", > "out.txt)[/code]Note that in this case we pipe the result to the IRAF MATCH task and then redirect to the output file explicitly from there. For more about CL scripting I'd recommend you see the Introductory Script Guide (https://iraf.net/irafdocs/script/).Lastly, I would note that your example uses the '>' operator and so each time you call ls you are overwriting the 'fitfiles.txt' file instead of appending to it (use '>>' for appending). An even simpler way to do this is using the unix 'find' command, i.e.[code]cl> !find maindir -name \*fit\* -print > fitfiles.txt[/code]
|
|
|
|
| |
|
Content generated in: 0.08 seconds |
|