Where is the command lines stored before it is executed?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












I have such a script in ~/draft



$ cat test.sh
#! /usr/local/bin/bash

for i in ./*;do
echo $i
done


The chunk of code are stored in test.sh,

when I run it



$ bash test.sh
./first.html
./second.html
./test.sh
./third.html


So I run the script name test.sh and get the output.



Alternatively, I could run the command directly as:



$ for i in ./*; do echo $i; done
./first.html
./second.html
./test.sh
./third.html


The second chunk get the identical results.



Since the preceding codes resides in file test.sh, what's the filename where the command for i in ./*; do echo $i; done live?










share|improve this question









New contributor




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























    up vote
    -1
    down vote

    favorite












    I have such a script in ~/draft



    $ cat test.sh
    #! /usr/local/bin/bash

    for i in ./*;do
    echo $i
    done


    The chunk of code are stored in test.sh,

    when I run it



    $ bash test.sh
    ./first.html
    ./second.html
    ./test.sh
    ./third.html


    So I run the script name test.sh and get the output.



    Alternatively, I could run the command directly as:



    $ for i in ./*; do echo $i; done
    ./first.html
    ./second.html
    ./test.sh
    ./third.html


    The second chunk get the identical results.



    Since the preceding codes resides in file test.sh, what's the filename where the command for i in ./*; do echo $i; done live?










    share|improve this question









    New contributor




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





















      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      I have such a script in ~/draft



      $ cat test.sh
      #! /usr/local/bin/bash

      for i in ./*;do
      echo $i
      done


      The chunk of code are stored in test.sh,

      when I run it



      $ bash test.sh
      ./first.html
      ./second.html
      ./test.sh
      ./third.html


      So I run the script name test.sh and get the output.



      Alternatively, I could run the command directly as:



      $ for i in ./*; do echo $i; done
      ./first.html
      ./second.html
      ./test.sh
      ./third.html


      The second chunk get the identical results.



      Since the preceding codes resides in file test.sh, what's the filename where the command for i in ./*; do echo $i; done live?










      share|improve this question









      New contributor




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











      I have such a script in ~/draft



      $ cat test.sh
      #! /usr/local/bin/bash

      for i in ./*;do
      echo $i
      done


      The chunk of code are stored in test.sh,

      when I run it



      $ bash test.sh
      ./first.html
      ./second.html
      ./test.sh
      ./third.html


      So I run the script name test.sh and get the output.



      Alternatively, I could run the command directly as:



      $ for i in ./*; do echo $i; done
      ./first.html
      ./second.html
      ./test.sh
      ./third.html


      The second chunk get the identical results.



      Since the preceding codes resides in file test.sh, what's the filename where the command for i in ./*; do echo $i; done live?







      bash






      share|improve this question









      New contributor




      rider dragon 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




      rider dragon 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 3 mins ago









      Kusalananda

      111k15216342




      111k15216342






      New contributor




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









      asked 1 hour ago









      rider dragon

      22716




      22716




      New contributor




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





      New contributor





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






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




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Commands don't have to be stored in a file to be executed - the interpreter (in this case bash) can simply read the command line into memory like it would read a script file (with some minor caveats related to buffering) and then execute it in exactly the same way.






          share|improve this answer




















            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            rider dragon 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%2f477670%2fwhere-is-the-command-lines-stored-before-it-is-executed%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            Commands don't have to be stored in a file to be executed - the interpreter (in this case bash) can simply read the command line into memory like it would read a script file (with some minor caveats related to buffering) and then execute it in exactly the same way.






            share|improve this answer
























              up vote
              0
              down vote













              Commands don't have to be stored in a file to be executed - the interpreter (in this case bash) can simply read the command line into memory like it would read a script file (with some minor caveats related to buffering) and then execute it in exactly the same way.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                Commands don't have to be stored in a file to be executed - the interpreter (in this case bash) can simply read the command line into memory like it would read a script file (with some minor caveats related to buffering) and then execute it in exactly the same way.






                share|improve this answer












                Commands don't have to be stored in a file to be executed - the interpreter (in this case bash) can simply read the command line into memory like it would read a script file (with some minor caveats related to buffering) and then execute it in exactly the same way.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 34 mins ago









                l0b0

                26.8k17107236




                26.8k17107236




















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









                     

                    draft saved


                    draft discarded


















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












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











                    rider dragon 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%2f477670%2fwhere-is-the-command-lines-stored-before-it-is-executed%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay