Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ukma!wuarchive!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.programmer Subject: Re: how to truncate lines Message-ID: <11500@jpl-devvax.JPL.NASA.GOV> Date: 19 Feb 91 22:19:47 GMT References: <1991Feb18.205238.14418@dartvax.dartmouth.edu> <1991Feb19.014649.133@mudos.ann-arbor.mi.us> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: usa Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 18 In article <1991Feb19.014649.133@mudos.ann-arbor.mi.us> mju@mudos.ann-arbor.mi.us (Marc Unangst) writes: : In article <1991Feb18.205238.14418@dartvax.dartmouth.edu> mdm@icefloe.dartmouth.edu (Michael McDaniel) writes: : >I am trying to write a simple shell script that will truncate lines fed : >from the standard input to 80 characters. I only want the first 80 : : cat file.with.really.long.lines | cut -c1-80 > file.with.shorter.lines perl -e 'print "*" x 1023, "\n"' | cut -c1-80 cut: ERROR: line too long perl -e 'print "*" x 2560, "\n"' | awk '{print substr($0,1,80)}' awk: record `********************...' too long perl -e 'print "*" x 1_000_000, "\n"' | perl -pe 'chop; $_=substr($_,0,80)."\n"' ******************************************************************************** Larry Wall lwall@jpl-devvax.jpl.nasa.gov