At 23:02 12.19.2001 -0500, KeN ClarK wrote:
>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. i can either send it to a new file and cat that into the signature
>script, or figure out a way to write my script over in perl. right now
>it's just a simple bash thing of 4 lines. my question is how can i read
>the output of w | head -1 into a file, and then remove all after the 3rd
>comma, to include the comma, and have that saved in a file?
>
>if there's a better way to do this, please advise. (after ghosting on this
>list for awhile, I see how there's alot of ways to do anything...) also,
>i'd like more or less pointers so i can kludge through this one myself.
Ok. So, I am quite confused on what you are really trying to do here but
the first thing that comes to mind is...
if you want your uptime...why are you using w | blah blah blah? You could
simply use uptime(1) couldn't you?
If you are really hell-bent on going the 'w | head -1' direction and
redirecting that into a file, you could simply do
w | head -1 > file
And the whole thing with the comma?:
w | head -1 w | head -1 | awk -F ',' '{print ","$4","$5","$6}'
But frankly you could use uptime which is in-and-of-itself much cleaner:
uptime | awk -F ',' '{print ","$4","$5","$6}' >> $HOME/.signature
Now, you could also do something like this: ( because frankly, I think the
awk solution above is a little kludgy)
echo ",$(uptime | cut -d , -f 4-)" >> $HOME/.signature
This is a cleaner solution because you don't have to worry about what
uptime returns after the commas (-f 4- progma). I don't know the operator
used in awk to return everything after $"identifier" automatically but if
awk has such a thing then the awk solution would be quite clean as well.
Good luck
- Jim
>ken
>
> ____________________________________________________
>| |< e |\| http://www.quantifier.org GnuPG: 7C828670 |
>|_____________________________________________________|
> 10:45pm up 12 days, 2:41, 4 users, load average: 0.18, 0.12, 0.13
>
>
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
- 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...
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]