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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:03:42+00:00 2026-05-18T08:03:42+00:00

I was trying to write a script to execute a C program and measure

  • 0

I was trying to write a script to execute a C program and measure the time for execution using time command in Unix.

The script looks like follows

cc /home/pop/Daa/abc.c 

r = `time /home/pop/Daa/./a.out`

echo "recursion" $r >> log.txt

cc /home/pop/Daa/xyz.c

d = `time /home/pop/Daa/./a.out `

echo "dynamic" $d >> log.txt

But after executing the script the log.txt file contains only words recursion and dynamic. The time values seem to be missing. But executing time command on the commandline terminal gave the following output

real    0m0.001s
user    0m0.000s
sys 0m0.000s

How can get this output formatted to contain only the ‘real’ time of execution and written in the log file?

  • 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-05-18T08:03:43+00:00Added an answer on May 18, 2026 at 8:03 am

    The output of time goes to stderr. You have to redirect it.

    TIMEFORMAT=%R
    r=$( { time /home/pop/Daa/./a.out; } 2>&1 )
    

    And you can’t have spaces around the equal sign. It is preferable to use $() instead of backticks since it’s easier to read, there’s no confusion with single quotes and it’s easier to nest them.

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

Sidebar

Related Questions

I am trying to write a wrapper script for a command line program (svnadmin
I am trying to write a bash or PHP script that will execute a
I'm trying to write a powershell script which will execute sqlcmd.exe to run a
I am trying to write a Perl script using the utf8 pragma, and I'm
I am trying to write a Powershell script to run a general SQL command
When i am trying to write the code like document.getElementById('id1') after teh script tag
I am trying to write a PHP script which executes a shell command (via
I'm trying to write a jruby script that connects to an oracle database using
I'm trying to write a script to allow me to log in to a
I'm trying to write a script that informs the user when someone has logged

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.