Trouble looping commands

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Trouble looping commands
# 1  
Old 06-27-2018
Trouble looping commands

Hi,

I have encountered a problem that I am unable to find a workaround for. I have 52 numbers and I need to submit an individual job for each pair combination, so too many to do by hand.

I have created a submission file (submission_code.sh) which contains the following code:

Code:
gcta64 --reml-bivar $a $b --out out_$a_$b; sleep 1

And I have created a loop file which contains the following code:

Code:
for a in `seq 1 52`
 do
  for b in `seq 1 52`
   do
  echo $a $b
  bash submission_code.sh
 sleep 1
done
done

The code runs, but it does not pass over the sequence numbers from the loop file to the submission file. Instead for "a" and "b" that values used are 1 and 2, which are the default used by the programme.

Can anyone help with this?

Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 06-27-2018 at 04:00 PM.. Reason: Added CODE tags.
# 2  
Old 06-27-2018
Either put
Code:
gcta64 --reml-bivar $a $b --out out_$a_$b; sleep 1

directly into the for loops,
or pass them like
Code:
bash submission_code.sh "$a" "$b"

and have a submission_code.sh
Code:
gcta64 --reml-bivar "$1" "$2" --out out_"$1"_"$2"; sleep 1

This User Gave Thanks to MadeInGermany For This Post:
# 3  
Old 06-28-2018
Amazing, this is great! Thank you so much for your help, I really appreciate it
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Looping

Hey guys, so I am trying to do a loop script that will go through each folder (no gui so just each domain has a folder) and grab out the databases being used on that domain. I know I would use mysql -e "show databases where not 'information_schema';" once in each directory to pull the actual... (3 Replies)
Discussion started by: dough
3 Replies

2. Shell Programming and Scripting

Trouble using awk and sed commands

Hi i have a control file which i need to read. It is ',' separated. the 3rd parameter will be ';' separated. I have 2 files: /home/orig.txt /home/join.txt I need a O/P file name based on firstparameter_1.txt and it should have the content of /home/orig.txt and appended content from... (2 Replies)
Discussion started by: Ravindra Swan
2 Replies

3. Shell Programming and Scripting

Trouble passing commands with expect

Hello All, I hope someone could help me with this. I'm creating a shell script to run a process. The trouble is, part of the process has to be ran as a different user. I can 'su' to the user ok, but I'm having trouble passing a 'cd' command as well as some variables I set earlier in the... (1 Reply)
Discussion started by: bbbngowc
1 Replies

4. UNIX for Dummies Questions & Answers

Ps commands trouble

Hi, i am writing a bash file and need to list the command name and user for the busiest process ie the one using the greatest percentage of CPU time) im kind of stuck. i know you should get the highest CPU , sort column 3 then take off the head but i'm un sure how would i do that? echo... (2 Replies)
Discussion started by: ryoukii
2 Replies

5. Shell Programming and Scripting

Trouble executing piped shell commands in perl code

I am trying to execute a piped combination of shell commands inside a perl program. However, it is not working as desired. This is my program, i am trying to print only filenames from the output of ls -l $ cat list_test #!/usr/bin/perl -w use strict; my $count=0; my @list=`ls -l|awk... (4 Replies)
Discussion started by: sam05121988
4 Replies

6. Shell Programming and Scripting

trouble looping in script

I am having problem looping this script I want to give the user option to decide if they want to continue after each entry but then also loop it back to beginning so they can more to content of there testcase they just created. I fam new to scripting so loops are little tricky for me. code I... (7 Replies)
Discussion started by: andrew.p.mcderm
7 Replies

7. AIX

HACMP: difference between 'cl' commands and 'cli' commands

Hi all, I'm new in this forum. I'm looking for the difference between the HACMP commands with the prefix "cl" and "cli". The first type are under /usr/es/sbin/cluster/sbin directory and the second are under /usr/es/sbin/cluster/cspoc directory. I know that the first are called HACMP for AIX... (0 Replies)
Discussion started by: peppix
0 Replies

8. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

9. Shell Programming and Scripting

help with looping

vesselNames values: xxx yyy zzz vesselPlanned values: xxx zzz zzz zzz OIFS="" OIFS=$IFS IFS="\n" (2 Replies)
Discussion started by: finalight
2 Replies

10. Programming

code that reads commands from the standard i/p and executes the commands

Hello all, i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e... (4 Replies)
Discussion started by: Phrozen Smoke
4 Replies
Login or Register to Ask a Question