linux怎么用shell 將檔案的修改時間與當前系統時間相差多少秒 顯示出來
uj5u.com熱心網友回復:
shell做不到,自己寫一個程式吧,用stat函式獲取檔案資訊uj5u.com熱心網友回復:
#!/bin/bash
Time1=$(stat -t $1 | awk '{print $12}')
Time2=$(date +%s)
echo `expr $Time2 - $Time1`
uj5u.com熱心網友回復:
要指定檔案的uj5u.com熱心網友回復:
#!/bin/shcurrent_time=$(date +%s)
echo 當前時間${current_time}
file_time=$(stat -c %X test.c)
echo 修改時間${file_time}
uj5u.com熱心網友回復:
echo 時間差`expr $current_time - $file_time`uj5u.com熱心網友回復:
$1就是當前時間啊。./test.sh fileuj5u.com熱心網友回復:
$1就是檔案名啊。./test.sh file
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/241528.html
標籤:系統維護與使用區
上一篇:java動態修改洗掉DNS記錄,提示沒有授權update failed: not authoritative for update zone (NOTAUTH)
