1

How can date and time of execution of a program be loaded at middle of a program. Every time I use exec date command it seems to ignore everything beneath it.

3
  • 2
    Don't use exec in that context: it replaces the current shell with the command you give it. If you need more specific advice then post an example of code. Dec 9, 2015 at 15:55
  • echo "HELLO" ; exec date ; echo "HI" You got my point right, I need to print HELLO then date and time of exec time of a program and then HI
    – Gimmeray
    Dec 9, 2015 at 16:06
  • Please edit your question instead of posting the code in a comment. Dec 9, 2015 at 16:17

1 Answer 1

1

From help exec:

exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
    Replace the shell with the given command.

You don't want to replace the current shell (which will prevent script execution from reaching any subsequent commands): just use date

echo "HELLO"
date
echo "HI"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .