Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!sdd.hp.com!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven.umd.edu!umbc3.umbc.edu!math16.math.umbc.edu!rouben From: rouben@math16.math.umbc.edu (Rouben Rostamian) Newsgroups: comp.unix.shell Subject: Re: Best way to change a field ina file Message-ID: <1991Jun14.031352.6110@umbc3.umbc.edu> Date: 14 Jun 91 03:13:52 GMT References: <9735@cognos.UUCP> Sender: newspost@umbc3.umbc.edu (News posting account) Organization: University of Maryland Baltimore County, Mathmatics Department Lines: 17 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