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 8495063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:28:00+00:00 2026-06-10T23:28:00+00:00

In awk there are two output functions: print and printf . Are their implementations

  • 0

In awk there are two output functions: print and printf.

  • Are their implementations in awk very different?
  • What are the differences regarding performance/speed (if possible — theoretical, not only with “time” on command line)?
  • Do they use the same system calls?
  • 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-10T23:28:01+00:00Added an answer on June 10, 2026 at 11:28 pm
    1. The performance difference is probably not measurable.
    2. The print function outputs a newline at the end; printf does not unless requested.
    3. The print code converts the arguments to strings and then sends them to the output separated by the OFS (output field separator).
    4. The printf code might need to convert the string to a double before formatting it using a double format (%16.8g or something), and similar operations.
    5. The system call used is going to write(2) or something similar for both, but there’ll be code (probably <stdio.h>) layered above that.

    All that adds up to:

    • The implementations are different; print is a little simpler (and therefore faster) than printf.
    • The difference is probably not measurable for most purposes.
    • Use print if it will do what you need; use printf when it does what you need.
    • Don’t worry about it.

    And using a sprintf followed by print is likely to be slower than using printf directly, so don’t.

    In case of doubt, measure.

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

Sidebar

Related Questions

Is there a Git command equivalent to: git branch | awk '/\*/ { print
Possible Duplicate: eliminate unwanted output using awk and sed The following contents are there
Looking for an awk (or sed) one-liner to remove lines from the output if
Say I have two log files ( input.log and output.log ) with the following
I was reading this article today on two different regular expression algorithms. According to
At the moment here is what im doing ret=$(ls -la | awk '{print $3
I'm playing with awk and I'm trying to swap the first two fields of
I have a bash sequence, grep integer = $1 | awk -F= '{printf(%d\n,int($2*327))}' which
is there an easy away to combine fields in awk? Specifically, I have lines
Having never used awk before on Linux I am attempting to understand how it

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.