
如何在程式中間載入程式執行的日期和時間。每次我使用 exec date 命令時,它似乎都會忽略它下面的所有內容。
答案1
從help exec
:
exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
Replace the shell with the given command.
您不想替換目前的 shell(這將阻止腳本執行到達任何後續命令):只需使用date
echo "HELLO"
date
echo "HI"