Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!jaap+ From: jaap+@andrew.cmu.edu (Jaap Akkerhuis) Newsgroups: comp.unix.questions Subject: Re: extracting "rest of line" in AWK Message-ID: Date: 25 Aug 89 17:56:09 GMT References: <3368@blake.acs.washington.edu> Distribution: na Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA Lines: 28 In-Reply-To: <3368@blake.acs.washington.edu> > Excerpts from netnews.comp.unix.questions: 25-Aug-89 extracting "rest of > line" i.. Mark Bader@cac.washingto (670) > 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? > If there were a shift command, then I could shift off the first 2 fields, but is there a way to simulate this? Allthough it is a bit ugly, you can empty the first two fields, so something like: { $1="\0"; $2="\0"; print $0 } Of course, now you will have two spaces in front of the line printed. If you want to get rid of this you need a for loop in the style of "{ for(i = 3; i < NF; i++) printf("%s ", $i); print ""}" or just filter them out with an "awk '{ $1=""; $2=""; print $0 }' | sed 's/^ //'". There are tons of other ways to do this as well. jaap