file manipulation (easy question I think)

Rouben Rostamian rouben at math9.math.umbc.edu
Tue Jun 18 09:19:51 AEST 1991


In article <1991Jun17.200748.19324 at msuinfo.cl.msu.edu> jpd at 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 at umbc.bitnet
Baltimore, MD 21228,  U.S.A.              internet: rouben at math9.math.umbc.edu



More information about the Comp.unix.questions mailing list