-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
At 00:26 12.20.2001 -0500, Steven Hetland wrote: > > -----Original Message----- > > > > right now i do > > > > w | head -1 > > > > and get what's below my signature. I want to clean that up, cutting it > > after the # of users, so that everything after AND including the third > > comma is removed from that line. Then take that and add it to my > > signature > > script. > >Maybe I misunderstood. I thought Ken was asking the opposite of what Jim >posted... > Indeed. He did ask to have the comma removed but I thought he wanted everything after the third comma (shrug...hehehe). I just misread his question. The second solution you posted would be what I would have suggested to be the best. >If you want a least effort solution, you can do it without perl. Just >modify your bash script: > > w | head -1 | cut -d, -f1-3 > >A cleaner way would be to just use uptime, as (correction) Jim said: > > uptime | cut -d, -f1-3 > > >Since it's a perl list, and you asked how to do it with perl... Yes. Thank you for doing this. I apologize for the OT'ness of my reply. :) Let me continue a perl tradition: perl -MShell -e 'chomp($uptime = uptime());($a,$b,$c) = split(/,/,$uptime);print "$a,$b,$c\n"' >There's probably a bazillion ways to accomplish this, but here's two ways: > >Example 1: >---------- >chomp($uptime = `uptime`); >$uptime =~ s/^([\w\s:]+(,[\w\s:]+){2}).*$/$1/; >print "$uptime\n"; > >Example 2: >---------- >chomp($uptime = `uptime`); >$uptime = join(',',(split(/,/, $uptime, 4))[0,1,2]); >print "$uptime\n"; - - Jim Philosophy is for those who have nothing better to do than wonder why philosophy is for those who have nothing better to do than... -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com> iQA/AwUBPCGMyNsnJUihkt7CEQJVQgCfYHCjMA9QjlJAUeneYhLl2iXRybEAn1wZ aN9sZqQPawOepw57Dpmh1hlk =rhdO -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]