[aklug] Re: Old Skool SED help requested

From: adam bultman <adamb@glaven.org>
Date: Fri Oct 15 2010 - 23:02:52 AKDT

You can do this:

for x in `grep ^daemon /etc/group |cut -d: -f4 |sed 's/,/ /g'`; do echo
$x; done

That will spit out each user in the group, one per line. You can't do
a replace of commas with newlines in solaris sed - at least, the solaris
on SPARC that I have access to. No trusted solaris, sadly. You
obviously don't want to echo them, I'm just trying to show you that you
don't need to have them one per line - although you could easily do that
this way.

I'm doing daemon, since I don't have a group 'jim'. Also, I'm grepping
for ^daemon, so it matches the group (at the beginning of the line), and
not a user in the group.

Anyway, there's one way. I would also suggest perl, since it can be used
to modify text very easily, and very similarly to sed.

I'd also suspect there's a way to do that with awk as well, but it's too
late and I want to go to bed.

Adam

On 10/15/2010 06:58 PM, Jim MacDonald wrote:
> As many of you know I am multi-lingual when it comes to OS usage. I have =
> M$ and Apple and Linux at home and I use Solaris at work.=20
>
> I am trying to right a script that uses grep, cut and sed to pull a =
> group of users out of /etc/groups to use as a basis for a while loop to =
> grep their home directory and the rdist to them on a remote machine.=20
>
> however, I am having a problem with sed that has been driving me mad for =
> a couple of days.=20
>
> If I want to do this in OSX I can do this:
>
> grep username /etc/group |cut -d: -f4 |sed `:,:\n:g`=20
>
> If I do it in Linux (Ubuntu, Meerkat) I can do this:
>
> grep jim /etc/group |cut -d: -f1|sed -r 's/,/\n/g'=20
>
> problem is I want to do it in Solaris, and not just any Solaris, Trusted =
> Solaris 8. Neither variation works. Any ideas?
> =20
> Jim MacDonald
> jim@macdonald.org
>
>
>
> ---------
> To unsubscribe, send email to<aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>
>

-- 
Adam
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Oct 15 23:03:00 2010

This archive was generated by hypermail 2.1.8 : Fri Oct 15 2010 - 23:03:00 AKDT