Why won't the for loop execute for more than 4 iterations?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
In the following script, the for loop only outputs till unph4. I tried to write the value of $coils directly but doesn't work as well. I tried other iteration values to see the maximum I am getting is 9 (does the iteration number have to be a single digit?)
coil=34;
bash_command = sprintf(['for ph in all/ph[1-$coil].niin' ...
'don' ...
' base=`basename $ph`;n' ...
' dir=`dirname $ph`;n' ...
' mag=$dir/"mag"$base:2;n' ...
' unph="unph"$base:2;n' ...
' prelude -a $mag -p $ph -u $unph -n 12&n' ...
'donen' ...
'waitn' ...
'gunzip -f unph*.gzn']);
unix(bash_command);
bash for
New contributor
add a comment |
up vote
0
down vote
favorite
In the following script, the for loop only outputs till unph4. I tried to write the value of $coils directly but doesn't work as well. I tried other iteration values to see the maximum I am getting is 9 (does the iteration number have to be a single digit?)
coil=34;
bash_command = sprintf(['for ph in all/ph[1-$coil].niin' ...
'don' ...
' base=`basename $ph`;n' ...
' dir=`dirname $ph`;n' ...
' mag=$dir/"mag"$base:2;n' ...
' unph="unph"$base:2;n' ...
' prelude -a $mag -p $ph -u $unph -n 12&n' ...
'donen' ...
'waitn' ...
'gunzip -f unph*.gzn']);
unix(bash_command);
bash for
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In the following script, the for loop only outputs till unph4. I tried to write the value of $coils directly but doesn't work as well. I tried other iteration values to see the maximum I am getting is 9 (does the iteration number have to be a single digit?)
coil=34;
bash_command = sprintf(['for ph in all/ph[1-$coil].niin' ...
'don' ...
' base=`basename $ph`;n' ...
' dir=`dirname $ph`;n' ...
' mag=$dir/"mag"$base:2;n' ...
' unph="unph"$base:2;n' ...
' prelude -a $mag -p $ph -u $unph -n 12&n' ...
'donen' ...
'waitn' ...
'gunzip -f unph*.gzn']);
unix(bash_command);
bash for
New contributor
In the following script, the for loop only outputs till unph4. I tried to write the value of $coils directly but doesn't work as well. I tried other iteration values to see the maximum I am getting is 9 (does the iteration number have to be a single digit?)
coil=34;
bash_command = sprintf(['for ph in all/ph[1-$coil].niin' ...
'don' ...
' base=`basename $ph`;n' ...
' dir=`dirname $ph`;n' ...
' mag=$dir/"mag"$base:2;n' ...
' unph="unph"$base:2;n' ...
' prelude -a $mag -p $ph -u $unph -n 12&n' ...
'donen' ...
'waitn' ...
'gunzip -f unph*.gzn']);
unix(bash_command);
bash for
bash for
New contributor
New contributor
edited Nov 22 at 1:24
Stephen Harris
23k24176
23k24176
New contributor
asked Nov 22 at 0:46
A. De
1
1
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
Because all/ph[1-34].nii
matches at most 4 files: all/ph1.nii
, all/ph2.nii
, all/ph3.nii
, and all/ph4.nii
.
In shell patterns, a construction of the form [
char1-
char2]
matches the characters which sort between char1 and char2; so [1-34]
matchs 1
, 2
, 3
and 4
.
You may want to change the for
loop to
for i in $(seq 1 $coil)
do
ph=all/ph$i.nii
...
done
Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
– A. De
Nov 22 at 19:57
It is working -- that's an error message from your applicationprelude
. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
– AlexP
Nov 22 at 21:30
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Because all/ph[1-34].nii
matches at most 4 files: all/ph1.nii
, all/ph2.nii
, all/ph3.nii
, and all/ph4.nii
.
In shell patterns, a construction of the form [
char1-
char2]
matches the characters which sort between char1 and char2; so [1-34]
matchs 1
, 2
, 3
and 4
.
You may want to change the for
loop to
for i in $(seq 1 $coil)
do
ph=all/ph$i.nii
...
done
Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
– A. De
Nov 22 at 19:57
It is working -- that's an error message from your applicationprelude
. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
– AlexP
Nov 22 at 21:30
add a comment |
up vote
2
down vote
Because all/ph[1-34].nii
matches at most 4 files: all/ph1.nii
, all/ph2.nii
, all/ph3.nii
, and all/ph4.nii
.
In shell patterns, a construction of the form [
char1-
char2]
matches the characters which sort between char1 and char2; so [1-34]
matchs 1
, 2
, 3
and 4
.
You may want to change the for
loop to
for i in $(seq 1 $coil)
do
ph=all/ph$i.nii
...
done
Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
– A. De
Nov 22 at 19:57
It is working -- that's an error message from your applicationprelude
. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
– AlexP
Nov 22 at 21:30
add a comment |
up vote
2
down vote
up vote
2
down vote
Because all/ph[1-34].nii
matches at most 4 files: all/ph1.nii
, all/ph2.nii
, all/ph3.nii
, and all/ph4.nii
.
In shell patterns, a construction of the form [
char1-
char2]
matches the characters which sort between char1 and char2; so [1-34]
matchs 1
, 2
, 3
and 4
.
You may want to change the for
loop to
for i in $(seq 1 $coil)
do
ph=all/ph$i.nii
...
done
Because all/ph[1-34].nii
matches at most 4 files: all/ph1.nii
, all/ph2.nii
, all/ph3.nii
, and all/ph4.nii
.
In shell patterns, a construction of the form [
char1-
char2]
matches the characters which sort between char1 and char2; so [1-34]
matchs 1
, 2
, 3
and 4
.
You may want to change the for
loop to
for i in $(seq 1 $coil)
do
ph=all/ph$i.nii
...
done
edited Nov 22 at 11:53
answered Nov 22 at 0:54
AlexP
6,9391024
6,9391024
Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
– A. De
Nov 22 at 19:57
It is working -- that's an error message from your applicationprelude
. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
– AlexP
Nov 22 at 21:30
add a comment |
Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
– A. De
Nov 22 at 19:57
It is working -- that's an error message from your applicationprelude
. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.
– AlexP
Nov 22 at 21:30
Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
– A. De
Nov 22 at 19:57
Thank you. However, it is still not working. I have files from all/ph1.nii to all/ph34.nii. I am getting the error 'Dimensions of matrices being concatenated are not consistent.' Not sure what that means. Can you please suggest anything else?
– A. De
Nov 22 at 19:57
It is working -- that's an error message from your application
prelude
. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.– AlexP
Nov 22 at 21:30
It is working -- that's an error message from your application
prelude
. It has nothing to do with the shell, or with Linux. I cannot possibly know what your application does, and what parameters and data it expects; you may want to ask on a specialized forum dedicated to the specific application.– AlexP
Nov 22 at 21:30
add a comment |
A. De is a new contributor. Be nice, and check out our Code of Conduct.
A. De is a new contributor. Be nice, and check out our Code of Conduct.
A. De is a new contributor. Be nice, and check out our Code of Conduct.
A. De is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483333%2fwhy-wont-the-for-loop-execute-for-more-than-4-iterations%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown