LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   formating console output (omitting parts you do not want) (https://www.linuxquestions.org/questions/linux-newbie-8/formating-console-output-omitting-parts-you-do-not-want-192028/)

bpk 06-10-2004 02:38 PM

formating console output (omitting parts you do not want)
 
So there is uptime, which gives me a format like this:

Code:

12:28:51 up 22:29, 4 users, load average: 0.05, 0.04, 0.01
But all I'd like is the time the machine is up, like so:

Code:

up 22:29
What tool could i pipe to to omit the rest of the line to acheive this?

Now...

How do I format it in such a day that it can pick up only the uptime.... when it can range from what you see above to

Code:

up 12 days
i did a `set list` in VI, no tabs in between feilds, just spaces....



I need a solution that will work both on various GNU/Linux distros AND BSD's

Nis 06-10-2004 02:44 PM

Code:

uptime | cut -d ',' -f 1 | sed -e "s/.*up/up/"

bpk 06-10-2004 03:22 PM

wanna make out?



thanks!

Nis 06-10-2004 03:25 PM

Glad it worked out for you. cut and sed can be very userful.

bpk 06-10-2004 04:05 PM

I knew there was something like cut, and sed and awk are *vey* useful. I'll admit tho that I need to learn more about these. I have some uncomitted time this weekend that I'll put towards learning more about these tools.

Something like doing a df -h and adding up the net total of disk space would be nice. These tools should help accomplish that.

thanks for the help.

J.W. 06-10-2004 04:43 PM

This may be slightly OT but if you are interesting in being able to tell at a glance what your uptime is, along with a lot of other useful stats, check out gkrellm. http://web.wt.net/~billw/gkrellm/gkrellm.html It's totally cool and gives you a central, graphical way to keep tabs on your system. -- J.W.

bpk 06-10-2004 07:32 PM

I don't run X on servers ;) but thanks for the suggestion.

torsmo is also a *very* nice app. I find it's interface much more appealing.


All times are GMT -5. The time now is 03:11 AM.