Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!xanth!mcnc!decvax!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.unix.questions Subject: Re: extracting "rest of line" in AWK Message-ID: <671@lakart.UUCP> Date: 27 Aug 89 13:28:34 GMT References: <3368@blake.acs.washington.edu> Distribution: na Organization: Lakart Corporation, Newton, MA Lines: 35 mbader@cac.washington.edu (Mark Bader) asks: > Does anyone know of a way to extract the "rest of the line" in awk.. > e.g. I have a line that looks like > > %% Heading "This is a Graph Heading" > > and I want to do a {print $3} to get the "This is a Graph Heading" part, > but this obviously dosen't work. Is there a way to do this? It's fairly grotesque, a lot of work, but the following should work, assuming you're not to worried about spaces. { for (i = 3; i <= NF; i++) { if (i == NF) { a = "\n"; } else { a = " "; } printf "%s%s", $i, a; } } Or somesuch. I'm making the above up as I type here, so I can't guarantee it, but it should provide a starting point. An alternative approah is to use length($1) and length($2) and substr(), but again that assumes a lot about the input record. Enough rambling, I'm not really an awk guru. We now return you to your regular news articles. -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+