我需要編寫一個bash腳本,它檢查一個新用戶是否在5秒內登錄,如果是,打印它的詳細信息:名稱,用戶名...... 我已經有了下面的代碼,它檢查如果新用戶已經登錄:如何保存來自兩個變量的更改?
originalusers=$(users)
sleep 5
newusers=$(users)
if diff -u <(echo "$originalusers") <(echo "$newusers")
then
echo "Nothing's changed"
exit 1
else echo "New user is logged in"
diff -u <(echo "$originalusers") <(echo "$newusers") >shell
謝謝veryyyy多!!!!!它正在工作!!!!! :DDDDD –