Re: [gentoo-user] OT: awk scripting
Hi, On Fri, 24 Mar 2006 14:34:22 +0100 (CET) Sascha Lucas [EMAIL PROTECTED] wrote: I want the awk analogon for cut -f2-, which prints fields #2 to #n. Is this possible? awk '{print $2???}' I'd do the following: awk '{$1=;print $0}' (awk recalculates $0 when $n is modified) This still leaves you with one OFS starting the line (between $1 and $2), you can get rid of this using awk '{$1=;print substr($0,lenght(OFS))}' -hwh -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: awk scripting
let's say you have a listing like this in a file name list.txt: aaa bbb aaa bbb aaa bbb aaa bbb aaa bbb if you wanna print the bbb column, you just have to do like this: cat list.txt | awk '{ print $2 }' if the listing is like this: aaa;bbb aaa;bbb aaa;bbb aaa;bbb aaa;bbb then you do: cat list.txt | awk -F';' '{ print $2 }' and so on. I sugest you read awk and gawk man pages for more info. they are very complete. regards, claudio. On 3/24/06, Sascha Lucas [EMAIL PROTECTED] wrote: Hi list, I want the awk analogon for cut -f2-, which prints fields #2 to #n. Is this possible? awk '{print $2???}' TIA, Sascha. -- gentoo-user@gentoo.org mailing list -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: awk scripting
On Friday 24 March 2006 07:34, Sascha Lucas [EMAIL PROTECTED] wrote about '[gentoo-user] OT: awk scripting': I want the awk analogon for cut -f2-, which prints fields #2 to #n. Is this possible? I think: awk '{shift; shift; print $0}' -- If there's one thing we've established over the years, it's that the vast majority of our users don't have the slightest clue what's best for them in terms of package stability. -- Gentoo Developer Ciaran McCreesh -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: awk scripting
On Fri, 24 Mar 2006, Hans-Werner Hilse wrote: awk '{$1=;print $0}' (awk recalculates $0 when $n is modified) This still leaves you with one OFS starting the line (between $1 and $2), you can get rid of this using awk '{$1=;print substr($0,lenght(OFS))}' thanks. the function lenght seems not defined. but substr($0,2) works. Sascha. -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: awk scripting
Hi, On Fri, 24 Mar 2006 16:15:09 +0100 (CET) Sascha Lucas [EMAIL PROTECTED] wrote: On Fri, 24 Mar 2006, Hans-Werner Hilse wrote: awk '{$1=;print $0}' (awk recalculates $0 when $n is modified) This still leaves you with one OFS starting the line (between $1 and $2), you can get rid of this using awk '{$1=;print substr($0,lenght(OFS))}' thanks. the function lenght seems not defined. but substr($0,2) works. That was a typo. Should of course be length. -hwh -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: awk scripting
Hi, On Fri, 24 Mar 2006 08:49:22 -0600 Boyd Stephen Smith Jr. [EMAIL PROTECTED] wrote: On Friday 24 March 2006 07:34, Sascha Lucas [EMAIL PROTECTED] wrote about '[gentoo-user] OT: awk scripting': I want the awk analogon for cut -f2-, which prints fields #2 to #n. Is this possible? I think: awk '{shift; shift; print $0}' Sad, but true: There's no shift in awk. -hwh -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: awk scripting
On Fri, 24 Mar 2006, Hans-Werner Hilse wrote: On Fri, 24 Mar 2006 16:15:09 +0100 (CET) Sascha Lucas [EMAIL PROTECTED] wrote: thanks. the function lenght seems not defined. but substr($0,2) works. That was a typo. Should of course be length. sorry. I was in a hurry and didn't noticed the that it's just a typo. Thanks again, Sascha. -- gentoo-user@gentoo.org mailing list