Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!udel!princeton!jonlab!jon From: jon@jonlab.UUCP (Jon H. LaBadie) Newsgroups: comp.unix.questions Subject: Re: extracting "rest of line" in AWK Summary: New AWK provides a more complete solution Message-ID: <803@jonlab.UUCP> Date: 5 Sep 89 04:54:04 GMT References: <3368@blake.acs.washington.edu> <671@lakart.UUCP> Distribution: na Organization: 4455 Province Line Rd., Princeton, NJ 08540 Lines: 37 In article <671@lakart.UUCP>, dg@lakart.UUCP (David Goodenough) writes: > 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. > SOLUTION DELETED New awk added a substitute function that can get rid of unwanted fields whild preserving the spacing in the rest of the record. For example, sub($1, "", $0) should get rid of field on while leaving the remainder of the record intact (including spacing). Repeating the above command should get rid of field one and two. An alternative, in one statement is sub($1 "[ ]*" $2 "[ ]*", "", $0) where each set of square brackets contains a tab and a space. Remember to preserve $1 and $2 if the logic of the program requires them at a later point in the code. Jon LaBadie -- Jon LaBadie {att, princeton, bcr}!jonlab!jon {att, attmail, bcr}!auxnj!jon