Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
/usr/bin/time only timing first component of pipeline

I am trying to time the following command and eventually want to output the result to a file (hence the use of /usr/bin/time. However, the command being timed is always seq 1 2 rather than the entirety of the command:

/usr/bin/time -v seq 1 2 | parallel ssh-keygen -G /folder/{}.candidate -b 768

Is there a way to make sure the whole command is timed and not just the first little part?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you are using bash it is easier to use the bash built-in:

$ time cmd1 | cmd2 | cmd3

will time the entire pipe.

If you really want to use the external time command, you have to run the pipe in a sub-shell:

$ /usr/bin/time sh -c 'cmd1 | cmd2 | cmd3'

or else you'd be piping the time instead of timing the pipe.

This syntax also has the nice side effect that it is easy to separate the output of the command and that of time:

$ /usr/bin/time sh -c 'cmd1 | cmd2 > cmdout.txt 2> cmderr.txt' 2>> time.txt

However, it has an extra difficulty in the quotes. If your command itself contains quotes, you may need to escape them in hard to read ways.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!