Why does print work with awk but echo doesn't?

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












0















To sum it up....



This works:



awk 'BEGIN FS=":"; 
print $1 $3 $5; ' /etc/passwd


But this doesn't:



awk 'BEGIN FS=":"; 
echo $1 $3 $5; ' /etc/passwd


I would like to know why.










share|improve this question



















  • 1





    print is a keyword in Awk; echo is a shell word. Your examples are Awk examples that happen to be run in a shell...

    – jasonwryan
    Mar 24 '16 at 4:34







  • 3





    1. because awk doesn't have an echo keyword, it has print instead. 2. because awk and sh (or bash/dash/zsh/ksh etc. and perl. and python) are different scripting languages and have different keywords and syntax.

    – cas
    Mar 24 '16 at 5:15















0















To sum it up....



This works:



awk 'BEGIN FS=":"; 
print $1 $3 $5; ' /etc/passwd


But this doesn't:



awk 'BEGIN FS=":"; 
echo $1 $3 $5; ' /etc/passwd


I would like to know why.










share|improve this question



















  • 1





    print is a keyword in Awk; echo is a shell word. Your examples are Awk examples that happen to be run in a shell...

    – jasonwryan
    Mar 24 '16 at 4:34







  • 3





    1. because awk doesn't have an echo keyword, it has print instead. 2. because awk and sh (or bash/dash/zsh/ksh etc. and perl. and python) are different scripting languages and have different keywords and syntax.

    – cas
    Mar 24 '16 at 5:15













0












0








0








To sum it up....



This works:



awk 'BEGIN FS=":"; 
print $1 $3 $5; ' /etc/passwd


But this doesn't:



awk 'BEGIN FS=":"; 
echo $1 $3 $5; ' /etc/passwd


I would like to know why.










share|improve this question
















To sum it up....



This works:



awk 'BEGIN FS=":"; 
print $1 $3 $5; ' /etc/passwd


But this doesn't:



awk 'BEGIN FS=":"; 
echo $1 $3 $5; ' /etc/passwd


I would like to know why.







awk echo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 at 21:30









Rui F Ribeiro

39.6k1479132




39.6k1479132










asked Mar 24 '16 at 4:24









user3271166user3271166

1615




1615







  • 1





    print is a keyword in Awk; echo is a shell word. Your examples are Awk examples that happen to be run in a shell...

    – jasonwryan
    Mar 24 '16 at 4:34







  • 3





    1. because awk doesn't have an echo keyword, it has print instead. 2. because awk and sh (or bash/dash/zsh/ksh etc. and perl. and python) are different scripting languages and have different keywords and syntax.

    – cas
    Mar 24 '16 at 5:15












  • 1





    print is a keyword in Awk; echo is a shell word. Your examples are Awk examples that happen to be run in a shell...

    – jasonwryan
    Mar 24 '16 at 4:34







  • 3





    1. because awk doesn't have an echo keyword, it has print instead. 2. because awk and sh (or bash/dash/zsh/ksh etc. and perl. and python) are different scripting languages and have different keywords and syntax.

    – cas
    Mar 24 '16 at 5:15







1




1





print is a keyword in Awk; echo is a shell word. Your examples are Awk examples that happen to be run in a shell...

– jasonwryan
Mar 24 '16 at 4:34






print is a keyword in Awk; echo is a shell word. Your examples are Awk examples that happen to be run in a shell...

– jasonwryan
Mar 24 '16 at 4:34





3




3





1. because awk doesn't have an echo keyword, it has print instead. 2. because awk and sh (or bash/dash/zsh/ksh etc. and perl. and python) are different scripting languages and have different keywords and syntax.

– cas
Mar 24 '16 at 5:15





1. because awk doesn't have an echo keyword, it has print instead. 2. because awk and sh (or bash/dash/zsh/ksh etc. and perl. and python) are different scripting languages and have different keywords and syntax.

– cas
Mar 24 '16 at 5:15










1 Answer
1






active

oldest

votes


















2














The structure of awk execution is: pattern action statements




Actions

    Action statements are enclosed in braces, and . Action statements
consist of the usual assignment, conditional, and looping statements
found in most languages. The operators, control statements, and
input/output statements available are patterned after those in C.





  • print is I/O statement of awk.



    From manpage:



    print Print the current record. The output record is terminated with the value of ORS.



  • Visit manual>The print Statement:




    The print Statement



    Use the print statement to produce output with simple, standardized formatting. You specify only the strings or numbers to print, in a list separated by commas. They are output, separated by single spaces, followed by a newline. The statement looks like this:



    print item1, item2, …




Visit man awk for more details.



Also note that:



PATTERNS AND ACTIONS
AWK is a line-oriented language. The pattern comes first, and then the action. Action statements are
enclosed in and . Either the pattern may be missing, or the action may be missing, but, of course, not
both. If the pattern is missing, the action is executed for every single record of input. A missing action
is equivalent to

print

which prints the entire record.



awk doesn't have echo keyword/statement.



$ man awk | grep echo | wc -l
0





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',
    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f271856%2fwhy-does-print-work-with-awk-but-echo-doesnt%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









    2














    The structure of awk execution is: pattern action statements




    Actions

        Action statements are enclosed in braces, and . Action statements
    consist of the usual assignment, conditional, and looping statements
    found in most languages. The operators, control statements, and
    input/output statements available are patterned after those in C.





    • print is I/O statement of awk.



      From manpage:



      print Print the current record. The output record is terminated with the value of ORS.



    • Visit manual>The print Statement:




      The print Statement



      Use the print statement to produce output with simple, standardized formatting. You specify only the strings or numbers to print, in a list separated by commas. They are output, separated by single spaces, followed by a newline. The statement looks like this:



      print item1, item2, …




    Visit man awk for more details.



    Also note that:



    PATTERNS AND ACTIONS
    AWK is a line-oriented language. The pattern comes first, and then the action. Action statements are
    enclosed in and . Either the pattern may be missing, or the action may be missing, but, of course, not
    both. If the pattern is missing, the action is executed for every single record of input. A missing action
    is equivalent to

    print

    which prints the entire record.



    awk doesn't have echo keyword/statement.



    $ man awk | grep echo | wc -l
    0





    share|improve this answer





























      2














      The structure of awk execution is: pattern action statements




      Actions

          Action statements are enclosed in braces, and . Action statements
      consist of the usual assignment, conditional, and looping statements
      found in most languages. The operators, control statements, and
      input/output statements available are patterned after those in C.





      • print is I/O statement of awk.



        From manpage:



        print Print the current record. The output record is terminated with the value of ORS.



      • Visit manual>The print Statement:




        The print Statement



        Use the print statement to produce output with simple, standardized formatting. You specify only the strings or numbers to print, in a list separated by commas. They are output, separated by single spaces, followed by a newline. The statement looks like this:



        print item1, item2, …




      Visit man awk for more details.



      Also note that:



      PATTERNS AND ACTIONS
      AWK is a line-oriented language. The pattern comes first, and then the action. Action statements are
      enclosed in and . Either the pattern may be missing, or the action may be missing, but, of course, not
      both. If the pattern is missing, the action is executed for every single record of input. A missing action
      is equivalent to

      print

      which prints the entire record.



      awk doesn't have echo keyword/statement.



      $ man awk | grep echo | wc -l
      0





      share|improve this answer



























        2












        2








        2







        The structure of awk execution is: pattern action statements




        Actions

            Action statements are enclosed in braces, and . Action statements
        consist of the usual assignment, conditional, and looping statements
        found in most languages. The operators, control statements, and
        input/output statements available are patterned after those in C.





        • print is I/O statement of awk.



          From manpage:



          print Print the current record. The output record is terminated with the value of ORS.



        • Visit manual>The print Statement:




          The print Statement



          Use the print statement to produce output with simple, standardized formatting. You specify only the strings or numbers to print, in a list separated by commas. They are output, separated by single spaces, followed by a newline. The statement looks like this:



          print item1, item2, …




        Visit man awk for more details.



        Also note that:



        PATTERNS AND ACTIONS
        AWK is a line-oriented language. The pattern comes first, and then the action. Action statements are
        enclosed in and . Either the pattern may be missing, or the action may be missing, but, of course, not
        both. If the pattern is missing, the action is executed for every single record of input. A missing action
        is equivalent to

        print

        which prints the entire record.



        awk doesn't have echo keyword/statement.



        $ man awk | grep echo | wc -l
        0





        share|improve this answer















        The structure of awk execution is: pattern action statements




        Actions

            Action statements are enclosed in braces, and . Action statements
        consist of the usual assignment, conditional, and looping statements
        found in most languages. The operators, control statements, and
        input/output statements available are patterned after those in C.





        • print is I/O statement of awk.



          From manpage:



          print Print the current record. The output record is terminated with the value of ORS.



        • Visit manual>The print Statement:




          The print Statement



          Use the print statement to produce output with simple, standardized formatting. You specify only the strings or numbers to print, in a list separated by commas. They are output, separated by single spaces, followed by a newline. The statement looks like this:



          print item1, item2, …




        Visit man awk for more details.



        Also note that:



        PATTERNS AND ACTIONS
        AWK is a line-oriented language. The pattern comes first, and then the action. Action statements are
        enclosed in and . Either the pattern may be missing, or the action may be missing, but, of course, not
        both. If the pattern is missing, the action is executed for every single record of input. A missing action
        is equivalent to

        print

        which prints the entire record.



        awk doesn't have echo keyword/statement.



        $ man awk | grep echo | wc -l
        0






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 24 '16 at 5:22

























        answered Mar 24 '16 at 4:38









        PandyaPandya

        8,6591549103




        8,6591549103



























            draft saved

            draft discarded
















































            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%2f271856%2fwhy-does-print-work-with-awk-but-echo-doesnt%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

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

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay