shell编程题(十六)

题目:

root用户今天登陆了多长时间

答案:

#!/bin/bash

cat /proc/uptime | awk -F . '{run_days=$1/86400; run_hour=($1%86400)/3600;run_minute=($1%3600)/60;run_second=$1%60; printf("the operation is already running %d days %d hours %d minute %d seconds
", run_days, run_hour, run_minute, run_second)}'

运行结果:

原文地址:https://www.cnblogs.com/wanghao-boke/p/12152209.html