Nested for Loop In Directory
Clash Royale CLAN TAG#URR8PPP
I have two sets of files organized as such:
#first directory
/direc1/files
file0.1.tar.gz
file0.2.tar.gz
file0.3.tar.gz
file0.4.tar.gz
.
.
.
file0.22.tar.gz
In this directory, I have 242 files in total.
My current nested command to run script.py is below:
for z in `seq 0 10`; do
for i in `seq 1 22`; do python script.py --l2 --ld-wind-cm 1 --annot file$z.$i --thin-annot --out file$z.$i --print-snps;done;done
If you notice, I have hardcoded file
in this loop. Is there a way to run this without using file$z.$i
and instead using a variable?
shell-script
add a comment |
I have two sets of files organized as such:
#first directory
/direc1/files
file0.1.tar.gz
file0.2.tar.gz
file0.3.tar.gz
file0.4.tar.gz
.
.
.
file0.22.tar.gz
In this directory, I have 242 files in total.
My current nested command to run script.py is below:
for z in `seq 0 10`; do
for i in `seq 1 22`; do python script.py --l2 --ld-wind-cm 1 --annot file$z.$i --thin-annot --out file$z.$i --print-snps;done;done
If you notice, I have hardcoded file
in this loop. Is there a way to run this without using file$z.$i
and instead using a variable?
shell-script
This stopped being the same question when you brought a second directory into it. Having it there pretty much invalidates the existing answers. Please, write your questions so that they include all the necessary detail.
– ilkkachu
Dec 16 at 18:04
Ok, I'll make a new question instead. Thanks.
– Workhorse
Dec 16 at 18:12
add a comment |
I have two sets of files organized as such:
#first directory
/direc1/files
file0.1.tar.gz
file0.2.tar.gz
file0.3.tar.gz
file0.4.tar.gz
.
.
.
file0.22.tar.gz
In this directory, I have 242 files in total.
My current nested command to run script.py is below:
for z in `seq 0 10`; do
for i in `seq 1 22`; do python script.py --l2 --ld-wind-cm 1 --annot file$z.$i --thin-annot --out file$z.$i --print-snps;done;done
If you notice, I have hardcoded file
in this loop. Is there a way to run this without using file$z.$i
and instead using a variable?
shell-script
I have two sets of files organized as such:
#first directory
/direc1/files
file0.1.tar.gz
file0.2.tar.gz
file0.3.tar.gz
file0.4.tar.gz
.
.
.
file0.22.tar.gz
In this directory, I have 242 files in total.
My current nested command to run script.py is below:
for z in `seq 0 10`; do
for i in `seq 1 22`; do python script.py --l2 --ld-wind-cm 1 --annot file$z.$i --thin-annot --out file$z.$i --print-snps;done;done
If you notice, I have hardcoded file
in this loop. Is there a way to run this without using file$z.$i
and instead using a variable?
shell-script
shell-script
edited Dec 16 at 18:10
asked Dec 15 at 21:55
Workhorse
1104
1104
This stopped being the same question when you brought a second directory into it. Having it there pretty much invalidates the existing answers. Please, write your questions so that they include all the necessary detail.
– ilkkachu
Dec 16 at 18:04
Ok, I'll make a new question instead. Thanks.
– Workhorse
Dec 16 at 18:12
add a comment |
This stopped being the same question when you brought a second directory into it. Having it there pretty much invalidates the existing answers. Please, write your questions so that they include all the necessary detail.
– ilkkachu
Dec 16 at 18:04
Ok, I'll make a new question instead. Thanks.
– Workhorse
Dec 16 at 18:12
This stopped being the same question when you brought a second directory into it. Having it there pretty much invalidates the existing answers. Please, write your questions so that they include all the necessary detail.
– ilkkachu
Dec 16 at 18:04
This stopped being the same question when you brought a second directory into it. Having it there pretty much invalidates the existing answers. Please, write your questions so that they include all the necessary detail.
– ilkkachu
Dec 16 at 18:04
Ok, I'll make a new question instead. Thanks.
– Workhorse
Dec 16 at 18:12
Ok, I'll make a new question instead. Thanks.
– Workhorse
Dec 16 at 18:12
add a comment |
2 Answers
2
active
oldest
votes
Your request is not quite clear. Why the two loops across the two ranges? Wouldn't
for FN in *.tar.gz; do echo python script.py --out "$FN"; done
be sufficient? Remove the echo
if happy with the result.
If there is NO other file than the ones you want to work upon, the "extensions" can go away as well, run the for
loop across *
.
Hi, I have clarified my question, if that is ok?
– Workhorse
Dec 16 at 1:23
add a comment |
If there are other tar.gz files there besides those files you need you can use:
for i in file0..10.1..22.tar.gz; do python script.py --out "$i" --print-file; done
If these are the only files in the folder then this is sufficient, and will work with any file name.
for i in * ; do python script.py --out "$i" --print-file; done
If these are the only tar.gz files in folder, but there are some other type of files there then this can be used and can work with any name of tar.gz files:
for i in *.tar.gz ; do python script.py --out "$i" --print-file; done
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f489223%2fnested-for-loop-in-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your request is not quite clear. Why the two loops across the two ranges? Wouldn't
for FN in *.tar.gz; do echo python script.py --out "$FN"; done
be sufficient? Remove the echo
if happy with the result.
If there is NO other file than the ones you want to work upon, the "extensions" can go away as well, run the for
loop across *
.
Hi, I have clarified my question, if that is ok?
– Workhorse
Dec 16 at 1:23
add a comment |
Your request is not quite clear. Why the two loops across the two ranges? Wouldn't
for FN in *.tar.gz; do echo python script.py --out "$FN"; done
be sufficient? Remove the echo
if happy with the result.
If there is NO other file than the ones you want to work upon, the "extensions" can go away as well, run the for
loop across *
.
Hi, I have clarified my question, if that is ok?
– Workhorse
Dec 16 at 1:23
add a comment |
Your request is not quite clear. Why the two loops across the two ranges? Wouldn't
for FN in *.tar.gz; do echo python script.py --out "$FN"; done
be sufficient? Remove the echo
if happy with the result.
If there is NO other file than the ones you want to work upon, the "extensions" can go away as well, run the for
loop across *
.
Your request is not quite clear. Why the two loops across the two ranges? Wouldn't
for FN in *.tar.gz; do echo python script.py --out "$FN"; done
be sufficient? Remove the echo
if happy with the result.
If there is NO other file than the ones you want to work upon, the "extensions" can go away as well, run the for
loop across *
.
edited Dec 15 at 23:09
ilkkachu
55.5k783151
55.5k783151
answered Dec 15 at 22:05
RudiC
4,1491312
4,1491312
Hi, I have clarified my question, if that is ok?
– Workhorse
Dec 16 at 1:23
add a comment |
Hi, I have clarified my question, if that is ok?
– Workhorse
Dec 16 at 1:23
Hi, I have clarified my question, if that is ok?
– Workhorse
Dec 16 at 1:23
Hi, I have clarified my question, if that is ok?
– Workhorse
Dec 16 at 1:23
add a comment |
If there are other tar.gz files there besides those files you need you can use:
for i in file0..10.1..22.tar.gz; do python script.py --out "$i" --print-file; done
If these are the only files in the folder then this is sufficient, and will work with any file name.
for i in * ; do python script.py --out "$i" --print-file; done
If these are the only tar.gz files in folder, but there are some other type of files there then this can be used and can work with any name of tar.gz files:
for i in *.tar.gz ; do python script.py --out "$i" --print-file; done
add a comment |
If there are other tar.gz files there besides those files you need you can use:
for i in file0..10.1..22.tar.gz; do python script.py --out "$i" --print-file; done
If these are the only files in the folder then this is sufficient, and will work with any file name.
for i in * ; do python script.py --out "$i" --print-file; done
If these are the only tar.gz files in folder, but there are some other type of files there then this can be used and can work with any name of tar.gz files:
for i in *.tar.gz ; do python script.py --out "$i" --print-file; done
add a comment |
If there are other tar.gz files there besides those files you need you can use:
for i in file0..10.1..22.tar.gz; do python script.py --out "$i" --print-file; done
If these are the only files in the folder then this is sufficient, and will work with any file name.
for i in * ; do python script.py --out "$i" --print-file; done
If these are the only tar.gz files in folder, but there are some other type of files there then this can be used and can work with any name of tar.gz files:
for i in *.tar.gz ; do python script.py --out "$i" --print-file; done
If there are other tar.gz files there besides those files you need you can use:
for i in file0..10.1..22.tar.gz; do python script.py --out "$i" --print-file; done
If these are the only files in the folder then this is sufficient, and will work with any file name.
for i in * ; do python script.py --out "$i" --print-file; done
If these are the only tar.gz files in folder, but there are some other type of files there then this can be used and can work with any name of tar.gz files:
for i in *.tar.gz ; do python script.py --out "$i" --print-file; done
edited Dec 15 at 23:09
ilkkachu
55.5k783151
55.5k783151
answered Dec 15 at 22:10
rAlen
845510
845510
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f489223%2fnested-for-loop-in-directory%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
This stopped being the same question when you brought a second directory into it. Having it there pretty much invalidates the existing answers. Please, write your questions so that they include all the necessary detail.
– ilkkachu
Dec 16 at 18:04
Ok, I'll make a new question instead. Thanks.
– Workhorse
Dec 16 at 18:12