Filtering text from a string

I'm trying to write a script which prints out the users who are loged in.
Printing the output of the "users" command isn't the problem. What I want is to filter out my own username.

users | grep -v (username)

does not work because the whole line in which username exists is suppressed.

If somebody knows the solution, please let me know.

-Cozmic

Which flavor of UNIX are you using?

what about: who | grep -v username

or if you dont want tty info: who | grep -v username | awk '{print $1}'

who | grep -v username | awk '{print $1}'

works just fine for my purpose.

But still there is the issue of filtering text from a string, so that you can print the rest of the string contents. Or the other way around. Printing just the text (or the word(s) that matches the search criteria) you're looking for.

If you ask me grep should do it. But extending grep is to mutch work (or perhaps I'm to lazy :)).
The challenge is to do this with a script.

PS: I'm using FreeBSD.

[Edited by Cozmic on 03-15-2001 at 06:31 AM]

grep can only print out (or exclude if using -v) whole lines.

You could have used sed to remove part of the line:
users | sed 's/username//g'

Of cource somebody ran into this problem allready!
It was pretty ignorant of me to think that it wasn't allready solved :rolleyes:.

Thanks PxT. This is just what I was looking for.