[comp.unix.shell] Best way to change a field ina file

maklinm@cognos.UUCP (Maxwell Maklin) (06/13/91)

Sorry, just a novice.  I was wondering what is the preferred way
to edit a field within a file.  I suppose sed(1V) is the preferred
choice, but I want to take a file as stdin, change a field and have
the changed file be place on stdout.  For example, how would one
change "gcos-field" in the /etc/passwd file?

Thanks,

Max

rouben@math16.math.umbc.edu (Rouben Rostamian) (06/14/91)

In article <9735@cognos.UUCP> maklinm@cognos.UUCP (Maxwell Maklin) writes:
>Sorry, just a novice.  I was wondering what is the preferred way
>to edit a field within a file.  I suppose sed(1V) is the preferred
>choice, but I want to take a file as stdin, change a field and have
>the changed file be place on stdout.  For example, how would one
>change "gcos-field" in the /etc/passwd file?

I suspect that in your message you are not saying what you meant to say,
but if you said what you meant to say, then what you do is:

... [standin here] ... | sed 's/old field/new field/' | ... [standout here] ...

--
Rouben Rostamian                          Telephone: (301) 455-2458
Department of Mathematics and Statistics  e-mail:
University of Maryland Baltimore County   bitnet: rostamian@umbc.bitnet
Baltimore, MD 21228,  U.S.A.              internet: rouben@math9.math.umbc.edu