Sponsored Content
Full Discussion: Nested loop in Unix
Top Forums Shell Programming and Scripting Nested loop in Unix Post 302416339 by moon218 on Monday 26th of April 2010 07:04:09 AM
Old 04-26-2010
Lightbulb Nested loop in Unix

Hi,
I have the following script which is two while loops, but it is working only for the Inner loop without going back to the outer loop.

the aim of this script is to remove data files from memory after each five times for each setting of the rotate parameter

Code:
#!/bin/csh
set hdir = /home/stud/s3192861/researchM
set collbig = $hdir/small
set collsmall = $hdir/tiny
cd $hdir
@ test = 1
@ test2 = 1
while ($test < 10)
while ($test2 < 5)
date > rotation.big.$test.$test2
time $hdir/tree -rotate $test2 -vocab $collbig >> results/rotation.big.$test.$test2
@ test2 = $test2 + 1
end
@ test = $test + 2
./flushit $collbig
end

Any one can help please??

Last edited by Scott; 04-26-2010 at 08:05 AM.. Reason: Removed formatting and added code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

nested loop

I have two do loops. When I break of the inner loop it doesn't go back to the outer loop but exit the program. (5 Replies)
Discussion started by: chinog
5 Replies

2. Shell Programming and Scripting

Variable in While Loop Nested If

Hi all, I'm having problems with the setting a variable in a nested if statement. It doesn't seem to change even if it mets the 'if' condition. My script essentially looks for a user name from the output from a kerberos command. When I find the user name, I tried to change a variable and exit... (6 Replies)
Discussion started by: geass
6 Replies

3. Shell Programming and Scripting

nested loop problem

Please see the following script. basic="a b c" advance="d e f" A="basic advance" for g in $A do echo $g done The result would be obviously basic advance I want to ask how can i get the following result using $A in for loop a b c (5 Replies)
Discussion started by: mmunir
5 Replies

4. Shell Programming and Scripting

Nested for loop in bash

Hi, How to use values in one for loop to other for loop. say "$sf_rel" variable has values "2011/W2 2011/G2" I want to use these values in inner for loop to process properly. $branch variable has G2 and 6 What is happening is outer for loop $i has 2011/W2 it is entering into inner... (3 Replies)
Discussion started by: Anjan1
3 Replies

5. UNIX for Dummies Questions & Answers

Nested loop code

Greetings, Would anyone be able to tell me why this nested loop doesn't seem to work in any variation? for i in {1..8} do echo "i is "$i for j in {1..i} do echo "j is "$j done doneoutput is always along the lines of i is 1... (7 Replies)
Discussion started by: barnhillec
7 Replies

6. Shell Programming and Scripting

Nested if loop

Hi Team, I just want to check whether my nested if loop used is correct or not. if ] if ] export1 else export2 fi else if ] export3 else export4 fi fi Thanks Shiva (5 Replies)
Discussion started by: shivashankar_S
5 Replies

7. Shell Programming and Scripting

Nested for loop not ending

Hi All, Need help on below script for g in `cat /home/sid.txt` do for h in `cat /home/dev.txt` do symmaskdb -sid $g -dev $h list assign |grep FA |head -1|awk '{print $2}' > tt1.txt done done cat /home/sid.txt ************** 123 235 456 (5 Replies)
Discussion started by: ranjancom2000
5 Replies

8. Programming

MPI C++ in a nested loop

I have a MPI program like this: void slave1(int j){ MPI_Status status; MPI_Recv(&j,1,MPI_INT,0,0,MPI_COMM_WORLD,&status);} void slave2(int j){ MPI_Status status; MPI_Recv(&j,1,MPI_INT,0,1,MPI_COMM_WORLD,&status);} int main(int argc, char *argv){ int numprocs, rank; ... (0 Replies)
Discussion started by: wanliushao
0 Replies

9. UNIX for Dummies Questions & Answers

Nested loop -bash

I am using the following nested loop for i in {1..3} do for y in {1..3} do if ; then echo P0${i}R${y}.fas mv P0${i}R${y}.fas P${i}R${y}.fas read -t 5 fi done done I was wondering if I can use a character such as * or ? instead of my second variable y. I tried R in... (3 Replies)
Discussion started by: Xterra
3 Replies
DwtOpenHierarchy(3Dwt)													    DwtOpenHierarchy(3Dwt)

Name
       DwtOpenHierarchy - Allocates a hierarchy ID and opens all the UID files in the hierarchy.

Syntax
       #include <X11/DwtAppl.h>
       Cardinal DwtOpenHierarchy(num_files, file_names_list, ancillary_structures_list,
				 hierarchy_id_return)
	    DRMCount num_files;
	    String file_names_list [];
	    IDBOSOpenParamPtr *ancillary_structures_list;
	    DRMHierarchy *hierarchy_id_return;

Arguments
       num_files Specifies the number of files in the name list.

       file_names_list
		 Specifies an array of pointers to character strings that identify the .uid files.

       ancillary_structures_list
		 A list of operating system-dependent ancillary structures corresponding to such things as file names, clobber flag, and so forth.
		 This argument should be NULL for most operations.  If you need to reference this structure,  see  the	definition  of	IDBOSOpen-
		 ParamPtr in DwtAppl.h for more information.

       hierarchy_id_return
		 Returns  the search hierarchy ID.  The search hierarchy ID identifies the list of .uid files that DRM will search (in order) when
		 performing subsequent fetch calls.

Description
       The DwtOpenHierarchy function allows the user to specify the list of UID files that DRM will search in subsequent  fetch  operations.   All
       subsequent  fetch  operations  will  return  the first occurrence of the named item encountered while traversing the UID hierarchy from the
       first list element (UID file specification) to the last list element.  This function also allocates a hierarchy ID and opens  all  the  UID
       files  in the hierarchy.  It initializes the optimized search lists in the hierarchy.  If DwtOpenHierarchy encounters any errors during its
       execution, any files that were opened are closed.

       Each UID file specified in file_names_list can specify either a full directory pathname or a file name.	If a UID file does not specify the
       pathname it will not contain any embedded slashes (/),  and it will be accessed through the UIDPATH environment variable.

       The  UIDPATH environment variable specifies search paths and naming conventions associated with UID files.  It can contain the substitution
       fields %L and %N, where the current setting of the LANG environment variable is substituted for %L and the .uid name passed to DwtOpenHier-
       archy  is  substituted  for  %N.   For  example, the following UID path and DwtOpenHierarchy call would cause DRM to open two separate .uid
       files:

	UIDPATH=/uidlib/%L/%N.uid:/uidlib/%N/%L
	 static char *uid_files[] = {"/usr/users/me/test.uid", "test2"};
	  DRMHierarchy	*Hierarchy_id;
	  DwtOpenHierarchy((DRMCount)2,uid_files, NULL, Hierarchy_id)

       The first file, /usr/users/me/test.uid, would be opened as specified, as this file specification includes a  pathname.	The  second  file,
       test2, would be looked for first in /uidlib/$LANG/test2.uid, and second in /uidlib/test2/$LANG.

       After  DwtOpenHierarchy opens the UID hierarchy, you should not delete or modify the UID files until you close the UID hierarchy by calling
       DwtCloseHierarchy.

Return Values
       This function returns one of these status return constants:

       DRMSuccess	 The   function   executed
			 successfully.
       DRMNotFound	 File not found.
       DRMFailure	 The function failed.

See Also
       DwtCloseHierarchy(3Dwt)

															    DwtOpenHierarchy(3Dwt)
All times are GMT -4. The time now is 08:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy