Shell Script Question

Posted by jscholes, 03-13-2010, 08:55 AM
Hi, I have a Windows port of the Unix/Linux uptime command. It shows system uptime, but not CPU load averages or the number of users logged on. Example: I want similar output from the uptime command on my Linux server. I know how to do this with PHP, using string split functions, but have no idea how to do it in a Bash script. I believe I'd have to use regexp in some way, shape or form, but I'm a complete newby when it comes to regexp. Can anyone please help me with this? Current output of uptime command on Linux: Desired output: Thanks.

Posted by PCS-Chris, 03-13-2010, 10:47 AM
Quick and dirty but try uptime | cut -c 1-27

Posted by jscholes, 03-13-2010, 11:51 AM
Great, worked like a charm. Its not being used in a production environment or anything, so quick and dirty was just what I needed. Thanks.

¿Fue útil la respuesta?

 Imprimir éste Artículo

Leer también

What is L0 backup?

Posted by prashant1979, 06-27-2008, 09:09 AMWhat is L0 backup? How is it taken? If I have to take...

flushing iptables

Posted by hazarus, 09-16-2007, 04:34 AMhello, I keep trying to flush my iptables on my linux...

Sending commands to a socket (C++)

Posted by LindonNetworks, 09-19-2008, 05:53 PMI'm trying to write an SMTP wrapper and I'm...

Warning: shell_exec() has been disabled for security reasons

Posted by ashish1987, 09-15-2007, 12:39 AMHey I installed status2k on my server and i am...

Cronjob issue

Posted by CymraegWalesHosting, 11-16-2012, 11:25 PMHi all, Hopefully this is a simple fix....