Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!umbc3.umbc.edu!math9.math.umbc.edu!rouben From: rouben@math9.math.umbc.edu (Rouben Rostamian) Newsgroups: comp.unix.questions Subject: Re: file manipulation (easy question I think) Message-ID: <1991Jun17.231951.5873@umbc3.umbc.edu> Date: 17 Jun 91 23:19:51 GMT References: <1991Jun17.200748.19324@msuinfo.cl.msu.edu> Sender: newspost@umbc3.umbc.edu (News posting account) Organization: University of Maryland Baltimore County, Mathmatics Department Lines: 18 In article <1991Jun17.200748.19324@msuinfo.cl.msu.edu> jpd@tardis.cl.msu.edu (Joe P. DeCello) writes: > >What is this best (easiest) way in which to get the first word >of each line in a text file to a single line in a new text file? Depends what you mean why "word". If a "word" is taken to mean any contiguous sequence of non-blank characters, then following should do: sed 's/[ T]*\([^ T]*\).*/\1/' infile >outfile where I have typed a "T" to show a tab character. You should type a tab where you see a "T". -- 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