Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:43:52+00:00 2026-06-13T11:43:52+00:00

The example code is like this, it does the statistic of number of times

  • 0

The example code is like this, it does the statistic of number of times the first column appears and sort the result.

    { dist[$1]+=1; }
END { for (i in dist) {
        print i,dist[i] | "sort"
      }
    }

In my opinion, the process is like this:

(WORKFLOW A)

1) print all element in the dist, save them all to a buffer

2) get all elements in the buffer, and pipe them to sort function

But in the example above, the process looks like this:

(WORKFLOW B)

1) print one element in the dist, and then pipe it to sort function

2) process the next element in the dist, until no new element in dist

I was wondering why I shouldn’t place the sort like this:

    { dist[$1]+=1; }
END { for (i in dist) {
        print i,dist[i] 
      } 
      | "sort"
    }

Anyone has any idea about the reason? And how can I write the pipe if I want to do the work like WORKFLOW B?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:43:53+00:00Added an answer on June 13, 2026 at 11:43 am

    The reason you can’t do it the second way is because | "command" is part of the syntax of awk’s print command, it can’t be used with arbitrary statements or statement groups. The same thing goes for > filename.

    The way it works is that the first time it encounters a redirection to a file or pipe, it opens that file/pipe, and keeps that descriptor open. Then every time you redirect to the same file/pipe, it sends the output to the corresponding descriptor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For Example if i have my code like this (php): <?php somefunc(1); function somefunc($a)
Taking the jQuery framework for example, if you run code like this: $(document).ready(function init()
If I have a simple cucumber feature and scenario , like this (example code
example: http://jsfiddle.net/kuTLf/ code looks like this: <div id=main> <div id=slideshow class=pics> <div id=nav></div> <img
I would like to see how this example of existing code would be able
I constantly find myself writing similar code like the example below: if (object[Object Name]
Take a look at my code example at js bin: http://jsbin.com/iritep/3/edit I'd like to
Trying to customize Symfony2 form to produce html code looking like the following example:
Often I see javascript code where event handlers (like onmousemove) are assigned dynamically. Example:
Consider this example code: public class A<T> { public static T TheT { get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.