![](/img/trans.png)
[英]What is the command to print time\date with history in login shell script [on hold]
[英]Print current time and date when a command is issued in linux shell
我每次通過命令行在sift linux(ubuntu 14)上發出命令時都試圖將當前時間和日期打印到屏幕上。
例如
sansforensics@siftworkstation:$ fdisk -l image.dd
sansforensics@siftworkstation:$ output of command
current time and date
sansforensics@siftworkstation:$
我沒有尋找
start_time=`date +%s`
<command-to-execute>
end_time=`date +%s`
echo execution time was `expr $end_time - $start_time` s.
該命令會打印出命令運行所花費的時間,每次發出命令時都會查找當前日期和時間。
您在這里尋找PROMPT_COMMAND
:
PROMPT_COMMAND='date'
按照每個man bash
:
PROMPT_COMMAND
If set, the value is executed as a command prior to issuing each primary prompt.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.