Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!zaphod.mps.ohio-state.edu!samsung!olivea!mintaka!spdcc!dirtydog.ima.isc.com!ism.isc.com!ispd-newsserver!garden.ssd.kodak.com!weimer From: weimer@garden.ssd.kodak.com (Gary Weimer (253-7796)) Newsgroups: comp.unix.questions Subject: Re: file manipulation (easy question I think - REWORDED) Keywords: awk sed Message-ID: <1991Jun18.164800.27169@ssd.kodak.com> Date: 18 Jun 91 16:48:00 GMT References: <1991Jun18.014539.22085@msuinfo.cl.msu.edu> <1991Jun18.151428.22784@colorado.edu> Sender: news@ssd.kodak.com Reply-To: weimer@ssd.kodak.com Organization: Eastman Kodak Co.; Rochester, NY Lines: 36 In article <1991Jun18.151428.22784@colorado.edu>, lewis@tramp.Colorado.EDU (LEWIS WILLIAM M JR) writes: |> In article <1991Jun18.014539.22085@msuinfo.cl.msu.edu> jpd@tardis.cl.msu.edu (Joe P. DeCello) writes: |> > |> >To rephrase my previous question: |> > |> . . . |> >The best response to my previous posting was this: |> > |> >awk '{printf "%s ", $1' < infile > outfile |> > |> >I changed this to : |> > |> >awk '{printf "%s, ", $1' < infile > outfile |> > |> your solution simply needs another line. Also, note addition of closing |> brace: |> awk ' |> {printf "%s, ", $1} |> END {printf "\n"} |> ' < infile > outfile Execpt you left out the part that said: "but now I need to break off the first field of each line from the infile at the colon." What he really wants is: awk -F: '{if (NR==1) {printf "%s", $1} else {printf ", %s", $1}}' < in > out NOTES: -F: -- tells awk to use ':' as the field separator if (NR==1) etc. -- eliminates the trailing comma weimer@ssd.kodak.com ( Gary Weimer )