Date: Thu, 24 Feb 2005 20:03:44 +0100 From: FreeBSD questions mailing list <FreeBSD@amadeus.demon.nl> To: freebsd <freebsd-questions@freebsd.org> Cc: David Bear <David.Bear@asu.edu> Subject: Re: awk print Message-ID: <b554431ce631c265f47b52e3e8d31070@amadeus.demon.nl> In-Reply-To: <4c90b772050224033921bd036b@mail.gmail.com> References: <20050223214010.GA31005@asu.edu> <20050223221926.GB69249@slackbox.xs4all.nl> <20050224023605.GD31005@asu.edu> <20050224034132.GE3123@guinness.local.mark-and-erika.com> <4c90b772050224033921bd036b@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 24 feb 2005, at 12:39, Soheil Hassas Yeganeh wrote: > You can set $[1..n] to "" and then print > find ./ -name "stuff" | awk '{ $1=""; $2=""; print} > > > On Wed, 23 Feb 2005 22:41:32 -0500, Mark Frank > <mark@mark-and-erika.com> wrote: >> * On Wed, Feb 23, 2005 at 07:36:05PM -0700 David Bear wrote: >>> On Wed, Feb 23, 2005 at 11:19:26PM +0100, Roland Smith wrote: >>>> On Wed, Feb 23, 2005 at 02:40:10PM -0700, David Bear wrote: >>>>> I'm using awk to parse a directory listing. I was hoping there is a >>>>> way to tell awk to print from $2 - to the end of the columns >>>>> available. >>>>> >>>>> find ./ -name '*stuff' | awk '{FS="/" print $3---'} >>>> >>>> Is this what you mean?: >>>> >>>> find ./ -name '*stuff'|sed 's|\.[^/]*/[^/]*/||g' >>> >>> thanks for the advice. No, this doesn't do what I want. >>> >>> If I have a directory path /stuff/stuff/more/stuff/more/and/more >>> that is n-levels deep, I want to be able to cut off the first two >>> levels and print the from 2 to the Nth level. >> >> So how about cut? >> >> find ./ -name '*stuff'| cut -d/ -f4- >> >> Mark or if you insist on using awk: find ./ -name '*stuff' | awk '{for (i=3; i<=NF; i++) printf " %s", $i; printf "\n" }' Arno
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?b554431ce631c265f47b52e3e8d31070>