Place to discuss anything, almost. No politics, religion, Microsoft, or anything else that I (the nazi censor) deem inappropriate.
by Tux » Tue Jun 24, 2003 2:27 pm
How would I write a script that takes the output of the 'uptime' command and cuts out everything but the uptime. ie gets rid of load averages and current time etc
Advance Thanks (Sorry for the n00bish question)
-
Tux
- guru

-
- Posts: 689
- Joined: Wed Jan 08, 2003 10:40 am
by Void Main » Tue Jun 24, 2003 2:42 pm
To get what I have on the front page from the uptime command I do:
- Code: Select all
uptime | tr -s ' ' | cut -f3-7 -d' ' | cut -f1-2 -d','
which gives me this:
up 506 days, 1:09
Not sure if that's how you want it, if not you should get the idea...
-

Void Main
- Site Admin

-
- Posts: 5705
- Joined: Wed Jan 08, 2003 5:24 am
- Location: Tuxville, USA
-
by Tux » Tue Jun 24, 2003 2:57 pm
I do indeed, as usual, top advice

-
Tux
- guru

-
- Posts: 689
- Joined: Wed Jan 08, 2003 10:40 am
by Void Main » Tue Jun 24, 2003 3:13 pm
Or you could have done something like:
- Code: Select all
echo "scale=2;`cut -f1 -d' ' /proc/uptime`/60/60/24" | bc
-

Void Main
- Site Admin

-
- Posts: 5705
- Joined: Wed Jan 08, 2003 5:24 am
- Location: Tuxville, USA
-
Return to The Lounge
Who is online
Users browsing this forum: No registered users and 2 guests