LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-10-2004, 02:38 PM   #1
bpk
Member
 
Registered: Nov 2003
Location: San Francisco, CA
Distribution: FreeBSD, OpenBSD, Gentoo, OS X
Posts: 80

Rep: Reputation: 15
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
 
Old 06-10-2004, 02:44 PM   #2
Nis
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: Ubuntu Hoary (5.04)
Posts: 550

Rep: Reputation: 31
Code:
uptime | cut -d ',' -f 1 | sed -e "s/.*up/up/"
 
Old 06-10-2004, 03:22 PM   #3
bpk
Member
 
Registered: Nov 2003
Location: San Francisco, CA
Distribution: FreeBSD, OpenBSD, Gentoo, OS X
Posts: 80

Original Poster
Rep: Reputation: 15
wanna make out?



thanks!
 
Old 06-10-2004, 03:25 PM   #4
Nis
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: Ubuntu Hoary (5.04)
Posts: 550

Rep: Reputation: 31
Glad it worked out for you. cut and sed can be very userful.
 
Old 06-10-2004, 04:05 PM   #5
bpk
Member
 
Registered: Nov 2003
Location: San Francisco, CA
Distribution: FreeBSD, OpenBSD, Gentoo, OS X
Posts: 80

Original Poster
Rep: Reputation: 15
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.
 
Old 06-10-2004, 04:43 PM   #6
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Milwaukee, WI
Distribution: Mint
Posts: 6,642

Rep: Reputation: 69
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.
 
Old 06-10-2004, 07:32 PM   #7
bpk
Member
 
Registered: Nov 2003
Location: San Francisco, CA
Distribution: FreeBSD, OpenBSD, Gentoo, OS X
Posts: 80

Original Poster
Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
program console output using C xrado Programming 5 04-04-2005 02:48 PM
cp: omitting error jsolanky Linux - Software 10 11-28-2004 09:09 AM
How to disable console output kamel Programming 2 06-02-2004 01:41 PM
Sum of rows by formating output vimal480 Programming 8 09-03-2003 02:25 AM
Console output to X? dcm1878 Linux - Software 4 04-23-2003 08:07 PM


All times are GMT -5. The time now is 03:07 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration