How can I use a for loop to run a command over several files with unique output files? The...

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Difference between "generating set" and free product?

Would an alien lifeform be able to achieve space travel if lacking in vision?

Does Parliament hold absolute power in the UK?

Am I ethically obligated to go into work on an off day if the reason is sudden?

Is this wall load bearing? Blueprints and photos attached

Take groceries in checked luggage

Can the DM override racial traits?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Keeping a retro style to sci-fi spaceships?

What aspect of planet Earth must be changed to prevent the industrial revolution?

How to split my screen on my Macbook Air?

How to copy the contents of all files with a certain name into a new file?

Is every episode of "Where are my Pants?" identical?

What can I do if neighbor is blocking my solar panels intentionally?

Do working physicists consider Newtonian mechanics to be "falsified"?

Can the prologue be the backstory of your main character?

I could not break this equation. Please help me

In horse breeding, what is the female equivalent of putting a horse out "to stud"?

Problems with Ubuntu mount /tmp

Does Parliament need to approve the new Brexit delay to 31 October 2019?

Was credit for the black hole image misattributed?

how can a perfect fourth interval be considered either consonant or dissonant?

If the empty set is a subset of every set, why write ... ∪ {∅}?



How can I use a for loop to run a command over several files with unique output files?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election ResultsIn a bash shell script, writing a for loop that iterates over string valuesBash script for looping through filesCannot run command inside bash variable including square brackets with nullglobNot able to find Output files for multiple input using for loopHow to generate total size of files from each unique source in bashCan the command within for-loop affect the iterations?How do I loop over the lines in STDIN and run a shell command?What happens when files are added/removed in the middle of a “for f in *” sh loop?ffmpeg does not accept variable name read from fileHow to write linux find command with for loop on Jupyter





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I need to run a command with the below syntax for 1000 files in a directory and save the output to a unique file for each iteration.



command universalinputfile variableinputfile > outputfile


for example



MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_1rndb > motifoutput/output_1

MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_2rndb > motifoutput/output_2


I've tried using the below for loop without success.



for i in {1..1000}
do
MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_$irndb > motifoutput/output_$i
done


I've also tried the for loop with the "for file in /dir" format without success.



How can I do this?










share|improve this question









New contributor




begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Do you want randomseq_${i}rndb to scope the variable ${i} ?

    – Stephen Harris
    13 mins ago











  • Yes exactly. Each input file is named "randomseq_irndb" where i is a number 1 through 1000. I want to run the MotifPSSM command on all 1000 files and have a unique output file for each.

    – begginer_bioinformatics
    10 mins ago











  • Try your for loop with ${i}rndb. Your script had $irndb which is totally different; it's looking for a variable called irndb instead of a variable i followed by rndb

    – Stephen Harris
    9 mins ago




















0















I need to run a command with the below syntax for 1000 files in a directory and save the output to a unique file for each iteration.



command universalinputfile variableinputfile > outputfile


for example



MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_1rndb > motifoutput/output_1

MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_2rndb > motifoutput/output_2


I've tried using the below for loop without success.



for i in {1..1000}
do
MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_$irndb > motifoutput/output_$i
done


I've also tried the for loop with the "for file in /dir" format without success.



How can I do this?










share|improve this question









New contributor




begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Do you want randomseq_${i}rndb to scope the variable ${i} ?

    – Stephen Harris
    13 mins ago











  • Yes exactly. Each input file is named "randomseq_irndb" where i is a number 1 through 1000. I want to run the MotifPSSM command on all 1000 files and have a unique output file for each.

    – begginer_bioinformatics
    10 mins ago











  • Try your for loop with ${i}rndb. Your script had $irndb which is totally different; it's looking for a variable called irndb instead of a variable i followed by rndb

    – Stephen Harris
    9 mins ago
















0












0








0








I need to run a command with the below syntax for 1000 files in a directory and save the output to a unique file for each iteration.



command universalinputfile variableinputfile > outputfile


for example



MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_1rndb > motifoutput/output_1

MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_2rndb > motifoutput/output_2


I've tried using the below for loop without success.



for i in {1..1000}
do
MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_$irndb > motifoutput/output_$i
done


I've also tried the for loop with the "for file in /dir" format without success.



How can I do this?










share|improve this question









New contributor




begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I need to run a command with the below syntax for 1000 files in a directory and save the output to a unique file for each iteration.



command universalinputfile variableinputfile > outputfile


for example



MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_1rndb > motifoutput/output_1

MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_2rndb > motifoutput/output_2


I've tried using the below for loop without success.



for i in {1..1000}
do
MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_$irndb > motifoutput/output_$i
done


I've also tried the for loop with the "for file in /dir" format without success.



How can I do this?







linux bash






share|improve this question









New contributor




begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 14 mins ago









Stephen Harris

27.5k35383




27.5k35383






New contributor




begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 16 mins ago









begginer_bioinformaticsbegginer_bioinformatics

1




1




New contributor




begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






begginer_bioinformatics is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Do you want randomseq_${i}rndb to scope the variable ${i} ?

    – Stephen Harris
    13 mins ago











  • Yes exactly. Each input file is named "randomseq_irndb" where i is a number 1 through 1000. I want to run the MotifPSSM command on all 1000 files and have a unique output file for each.

    – begginer_bioinformatics
    10 mins ago











  • Try your for loop with ${i}rndb. Your script had $irndb which is totally different; it's looking for a variable called irndb instead of a variable i followed by rndb

    – Stephen Harris
    9 mins ago





















  • Do you want randomseq_${i}rndb to scope the variable ${i} ?

    – Stephen Harris
    13 mins ago











  • Yes exactly. Each input file is named "randomseq_irndb" where i is a number 1 through 1000. I want to run the MotifPSSM command on all 1000 files and have a unique output file for each.

    – begginer_bioinformatics
    10 mins ago











  • Try your for loop with ${i}rndb. Your script had $irndb which is totally different; it's looking for a variable called irndb instead of a variable i followed by rndb

    – Stephen Harris
    9 mins ago



















Do you want randomseq_${i}rndb to scope the variable ${i} ?

– Stephen Harris
13 mins ago





Do you want randomseq_${i}rndb to scope the variable ${i} ?

– Stephen Harris
13 mins ago













Yes exactly. Each input file is named "randomseq_irndb" where i is a number 1 through 1000. I want to run the MotifPSSM command on all 1000 files and have a unique output file for each.

– begginer_bioinformatics
10 mins ago





Yes exactly. Each input file is named "randomseq_irndb" where i is a number 1 through 1000. I want to run the MotifPSSM command on all 1000 files and have a unique output file for each.

– begginer_bioinformatics
10 mins ago













Try your for loop with ${i}rndb. Your script had $irndb which is totally different; it's looking for a variable called irndb instead of a variable i followed by rndb

– Stephen Harris
9 mins ago







Try your for loop with ${i}rndb. Your script had $irndb which is totally different; it's looking for a variable called irndb instead of a variable i followed by rndb

– Stephen Harris
9 mins ago












1 Answer
1






active

oldest

votes


















0














$irndb is read as a single variable called irndb. You can change the parse to use just i as the variable name with ${i}rndb:



for i in {1..1000}
do
MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_${i}rndb > motifoutput/output_$i
done


The for loop itself was fine, including the brace expansion {1..1000}, so you don't need to change that.





share
























    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
    });


    }
    });






    begginer_bioinformatics is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512344%2fhow-can-i-use-a-for-loop-to-run-a-command-over-several-files-with-unique-output%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    $irndb is read as a single variable called irndb. You can change the parse to use just i as the variable name with ${i}rndb:



    for i in {1..1000}
    do
    MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_${i}rndb > motifoutput/output_$i
    done


    The for loop itself was fine, including the brace expansion {1..1000}, so you don't need to change that.





    share




























      0














      $irndb is read as a single variable called irndb. You can change the parse to use just i as the variable name with ${i}rndb:



      for i in {1..1000}
      do
      MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_${i}rndb > motifoutput/output_$i
      done


      The for loop itself was fine, including the brace expansion {1..1000}, so you don't need to change that.





      share


























        0












        0








        0







        $irndb is read as a single variable called irndb. You can change the parse to use just i as the variable name with ${i}rndb:



        for i in {1..1000}
        do
        MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_${i}rndb > motifoutput/output_$i
        done


        The for loop itself was fine, including the brace expansion {1..1000}, so you don't need to change that.





        share













        $irndb is read as a single variable called irndb. You can change the parse to use just i as the variable name with ${i}rndb:



        for i in {1..1000}
        do
        MotifPSSM ../source/FruR-DPInteract.txt genrand/randomseq_${i}rndb > motifoutput/output_$i
        done


        The for loop itself was fine, including the brace expansion {1..1000}, so you don't need to change that.






        share











        share


        share










        answered 7 mins ago









        Michael HomerMichael Homer

        50.9k8141178




        50.9k8141178






















            begginer_bioinformatics is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            begginer_bioinformatics is a new contributor. Be nice, and check out our Code of Conduct.













            begginer_bioinformatics is a new contributor. Be nice, and check out our Code of Conduct.












            begginer_bioinformatics is a new contributor. Be nice, and check out our Code of Conduct.
















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512344%2fhow-can-i-use-a-for-loop-to-run-a-command-over-several-files-with-unique-output%23new-answer', 'question_page');
            }
            );

            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







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m