Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdcad!sun!pitstop!sundc!seismo!uunet!mcvax!philmds!leo
From: leo@philmds.UUCP (Leo de Wit)
Newsgroups: comp.unix.questions
Subject: Re: csh :t modifier (Was Re: basename(1) (Was Re:argv[0] in shellscript?))
Message-ID: <526@philmds.UUCP>
Date: 25 Jun 88 18:16:11 GMT
References: <3680037@eecs.nwu.edu> <1813@stpstn.UUCP> <709@ubu.warwick.UUCP>
Reply-To: leo@philmds.UUCP (L.J.M. de Wit)
Organization: Philips I&E DTS Eindhoven
Lines: 22

In article <709@ubu.warwick.UUCP> maujd@warwick.UUCP (Geoff Rimmer) writes:
> [other stuff deleted]...
>cat /etc/passwd | sed "s/:[^:]*:[^:]*:[^:]*:/	/" | sed "s/[,:].*//" | sort
>					   ^^TAB^^
>---------------------------------------------------------------------
>	(BTW, anyone got any improvements on this 'sed' line?)
>---------------------------------------------------------------------

You COULD of course use awk (using IFS) ...
but, assuming you're as devoted a sed worshipper as I am, yes, I've got
an improvement:
Don't use the cat; sed can open the file or even the shell can open it for
sed (saves a process).
Don't use sed twice; one is just as good (even faster).

So the result is:

sed -e "s/:[^:]*:[^:]*:[^:]*:/	/" -e "s/[,:].*//" /etc/passwd | sort

Now maybe even the sed could be improved upon ...?

      Leo.