Subtract time in two line

INPUT:

16:45:51 10051  77845
16:45:51 10051   77845

16:46:52 10051  77846
16:46:53 10051   77846

Match the last PID then subtract second line time with first line.

Please help me with any command or script.

Welcome vivekn,

Firstly, please wrap all code, files, input & output/errors in CODE tags. It makes them far easier to read and preserves spacing for indenting or fixed width data.

I have a few to questions pose in response:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

Kind regards,
Robin

1 Like

It on rhel7

---------- Post updated at 07:25 AM ---------- Previous update was at 05:03 AM ----------

Assignment,

Tried some awk command, but no success

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.

3 Likes