|
|
||||
|
||||
|
|
|
|||
|
Perl baby wrote:
> I have a file having fields in a matrix fashion. > What are the different ways in which I can print 3rd column of 5th row > (i.e. NF =3 and line = 5)?? > How many different ways of printing would you need? Hermann |
|
|||
|
On Nov 26, 12:19 pm, Hermann Peifer <pei...@gmx.eu> wrote:
> Perl baby wrote: > > I have a file having fields in a matrix fashion. > > What are the different ways in which I can print 3rd column of 5th row > > (i.e. NF =3 and line = 5)?? > > How many different ways of printing would you need? > > Hermann Wud be gr8 if u cud gimme atleast one. Thanks Awk Baby |
|
|||
|
On Thu, 26 Nov 2009 00:14:31 -0800 (PST), Perl baby <whereismelvin@gmail.com> wrote:
>On Nov 26, 12:19 pm, Hermann Peifer <pei...@gmx.eu> wrote: >> Perl baby wrote: >> > I have a file having fields in a matrix fashion. >> > What are the different ways in which I can print 3rd column of 5th row >> > (i.e. NF =3 and line = 5)?? >> >> How many different ways of printing would you need? >> >> Hermann > >Wud be gr8 if u cud gimme atleast one. Like: awk 'NR == 5 {print $3}' file Grant. -- http://bugsplatter.id.au |
|
|||
|
Perl baby wrote:
> On Nov 26, 12:19 pm, Hermann Peifer <pei...@gmx.eu> wrote: >> Perl baby wrote: >>> I have a file having fields in a matrix fashion. >>> What are the different ways in which I can print 3rd column of 5th row >>> (i.e. NF =3 and line = 5)?? >> How many different ways of printing would you need? >> >> Hermann > > Wud be gr8 if u cud gimme atleast one. > Try out how far you get with awk 'NR==5{print $3}' file Hermann |
|
|||
|
Thu, 26 Nov 2009 19:27:55 +1100, Grant did catÂ*:
> On Thu, 26 Nov 2009 00:14:31 -0800 (PST), Perl baby > <whereismelvin@gmail.com> wrote: > >>On Nov 26, 12:19 pm, Hermann Peifer <pei...@gmx.eu> wrote: >>> Perl baby wrote: >>> > I have a file having fields in a matrix fashion. What are the >>> > different ways in which I can print 3rd column of 5th row (i.e. NF >>> > =3 and line = 5)?? >>> >>> How many different ways of printing would you need? >>> >>> Hermann >> >>Wud be gr8 if u cud gimme atleast one. > > Like: > > awk 'NR == 5 {print $3}' file > > Grant. let's play "flog" for a change ;-) --------- awk -v col=3 -v row=5 ' FNR>row{ print a exit } FNR!=row{ next} { for(i=NF;i;--i){ if(i>col){continue} if(i<col){break} a=$(i) } } ' yerfile --------- |
|
|||
|
Loki Harfagr wrote:
>--------- >awk -v col=3 -v row=5 ' >FNR>row{ > print a > exit >} >FNR!=row{ next} >{ > for(i=NF;i;--i){ > if(i>col){continue} > if(i<col){break} > a=$(i) > } >} >' yerfile >--------- awk -v col=3 -v row=5 'FNR==row {print $(col); exit}' myfile -- Lorenz |
|
|||
|
Thu, 26 Nov 2009 13:03:22 +0000, Lorenz did catÂ*:
> Loki Harfagr wrote: >>--------- >>awk -v col=3 -v row=5 ' >>FNR>row{ >> print a >> exit >>} >>FNR!=row{ next} >>{ >> for(i=NF;i;--i){ >> if(i>col){continue} >> if(i<col){break} >> a=$(i) >> } >>} >>' yerfile >>--------- > > > awk -v col=3 -v row=5 'FNR==row {print $(col); exit}' myfile Well yes indeed but it may show you may have missed the "let's play 'flog' for a change ;-)" part? as the OP wanted an undefinite number of solutions here's another 'flog' way ,-) --------- awk -v col=3 -v row=5 ' !(FNR-row){ split($0,v) a=v[col] print a exit } FNR-row{ next } --------- |
|
|||
|
Loki Harfagr wrote:
>Thu, 26 Nov 2009 13:03:22 +0000, Lorenz did cat*: >[...] > Well yes indeed but it may show you may have missed the >"let's play 'flog' for a change ;-)" part? that may be (due to lack in knowledge about english proverbs) Lorenz (allready thinking about a getline version 8-) |
|
|||
|
On Fri, 27 Nov 2009 07:33:13 +0000, Lorenz <lorenznl@yahoo.com> wrote:
>Loki Harfagr wrote: >>Thu, 26 Nov 2009 13:03:22 +0000, Lorenz did catÂ*: >>[...] >> Well yes indeed but it may show you may have missed the >>"let's play 'flog' for a change ;-)" part? > >that may be (due to lack in knowledge about english proverbs) echo flog |rev Loki's from .fr > > >Lorenz (allready thinking about a getline version 8-) The boggle minds... Grant. -- http://bugsplatter.id.au |
|
|||
|
Fri, 27 Nov 2009 20:12:45 +1100, Grant did catÂ*:
> On Fri, 27 Nov 2009 07:33:13 +0000, Lorenz <lorenznl@yahoo.com> wrote: > >>Loki Harfagr wrote: >>>Thu, 26 Nov 2009 13:03:22 +0000, Lorenz did catÂ*: [...] >>> Well yes indeed but it may show you may have missed the >>>"let's play 'flog' for a change ;-)" part? >> >>that may be (due to lack in knowledge about english proverbs) > > echo flog |rev > > Loki's from .fr yup, and that'd make me a frog, maybe the reason why flog's a natural ;-) Or maybe Lorenz was thinking to that amelican plovelb? "Can't tell by looking at a flog how high he will jump." >> >>Lorenz (allready thinking about a getline version 8-) Noooo, get back!-) > > The boggle minds... as you requested boggle here's a last and boggling flog, I promise I won't push any other after that one ;-) ----------- awk -v col=3 -v row=5 ' { row-- while(++i){ a[++n]=$(i) if($(i)~/[\n]/){ row-- } if(!row){ while(++i){ a[++n]=$(i) if($(i)~/[ \t]/){ col-- if(!col){ for(p=n-1;p;p--){ printf("%s", a[n-p]) } printf("%s","\n") exit } n=0 delete(a) } } } } } ' RS= FS= yerfile ----------- |
|
|||
|
On Nov 27, 6:24*pm, Loki Harfagr <l...@thedarkdesign.free.fr.INVALID>
wrote: > Fri, 27 Nov 2009 20:12:45 +1100, Grant did cat*: > > > On Fri, 27 Nov 2009 07:33:13 +0000, Lorenz <loren...@yahoo.com> wrote: > > >>Loki Harfagr wrote: > >>>Thu, 26 Nov 2009 13:03:22 +0000, Lorenz did cat*: [...] > >>> Well yes indeed but it may show you may have missed the > >>>"let's play 'flog' for a change ;-)" part? > > >>that may be (due to lack in knowledge about english proverbs) > > > echo flog |rev > > > Loki's from .fr > > yup, and that'd make me a frog, maybe the reason why > flog's a natural ;-) > Or maybe Lorenz was thinking to that amelican plovelb? > "Can't tell by looking at a flog how high he will jump." > > > > >>Lorenz (allready thinking about a getline version 8-) > > Noooo, get back!-) > > > > > The boggle minds... > > as you requested boggle here's a last and boggling flog, > I promise I won't push any other after that one ;-) > ----------- > awk -v col=3 -v row=5 ' > { > * * * * row-- > * * * * while(++i){ > * * * * * * * * a[++n]=$(i) > * * * * * * * * if($(i)~/[\n]/){ > * * * * * * * * * * * * row-- > * * * * * * * * } > * * * * * * * * if(!row){ > * * * * * * * * * * * * while(++i){ > * * * * * * * * * * * * * * * * a[++n]=$(i) > * * * * * * * * * * * * * * * * if($(i)~/[ \t]/){ > * * * * * * * * * * * * * * * * * * * * col-- > * * * * * * * * * * * * * * * * * * * * if(!col){ > * * * * * * * * * * * * * * * * * * * * * * * * for(p=n-1;p;p--){ > * * * * * * * * * * * * * * * * * * * * * * * * * * * * printf("%s", a[n-p]) > * * * * * * * * * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * * * * * * * * * * * * * printf("%s","\n") > * * * * * * * * * * * * * * * * * * * * * * * * exit > * * * * * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * * * * * * * * * n=0 > * * * * * * * * * * * * * * * * * * * * delete(a) > * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * } > * * * * * * * * } > * * * * }} > > ' RS= FS= yerfile > ----------- awk -v LINE=2 -v COLUMN=5 'NR==LINE {print substr($0, COLUMN, 1); exit}' |
|
|||
|
On Nov 27, 6:24*pm, Loki Harfagr <l...@thedarkdesign.free.fr.INVALID>
wrote: > Fri, 27 Nov 2009 20:12:45 +1100, Grant did cat*: > > > On Fri, 27 Nov 2009 07:33:13 +0000, Lorenz <loren...@yahoo.com> wrote: > > >>Loki Harfagr wrote: > >>>Thu, 26 Nov 2009 13:03:22 +0000, Lorenz did cat*: [...] > >>> Well yes indeed but it may show you may have missed the > >>>"let's play 'flog' for a change ;-)" part? > > >>that may be (due to lack in knowledge about english proverbs) > > > echo flog |rev > > > Loki's from .fr > > yup, and that'd make me a frog, maybe the reason why > flog's a natural ;-) > Or maybe Lorenz was thinking to that amelican plovelb? > "Can't tell by looking at a flog how high he will jump." > > > > >>Lorenz (allready thinking about a getline version 8-) > > Noooo, get back!-) > > > > > The boggle minds... > > as you requested boggle here's a last and boggling flog, > I promise I won't push any other after that one ;-) > ----------- > awk -v col=3 -v row=5 ' > { > * * * * row-- > * * * * while(++i){ > * * * * * * * * a[++n]=$(i) > * * * * * * * * if($(i)~/[\n]/){ > * * * * * * * * * * * * row-- > * * * * * * * * } > * * * * * * * * if(!row){ > * * * * * * * * * * * * while(++i){ > * * * * * * * * * * * * * * * * a[++n]=$(i) > * * * * * * * * * * * * * * * * if($(i)~/[ \t]/){ > * * * * * * * * * * * * * * * * * * * * col-- > * * * * * * * * * * * * * * * * * * * * if(!col){ > * * * * * * * * * * * * * * * * * * * * * * * * for(p=n-1;p;p--){ > * * * * * * * * * * * * * * * * * * * * * * * * * * * * printf("%s", a[n-p]) > * * * * * * * * * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * * * * * * * * * * * * * printf("%s","\n") > * * * * * * * * * * * * * * * * * * * * * * * * exit > * * * * * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * * * * * * * * * n=0 > * * * * * * * * * * * * * * * * * * * * delete(a) > * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * } > * * * * * * * * } > * * * * }} > > ' RS= FS= yerfile > ----------- awk -v LINE=2 -v COLUMN=5 'NR==LINE {print substr($0, COLUMN, 1); exit}' |
|
|||
|
On Nov 27, 6:24*pm, Loki Harfagr <l...@thedarkdesign.free.fr.INVALID>
wrote: > Fri, 27 Nov 2009 20:12:45 +1100, Grant did cat*: > > > On Fri, 27 Nov 2009 07:33:13 +0000, Lorenz <loren...@yahoo.com> wrote: > > >>Loki Harfagr wrote: > >>>Thu, 26 Nov 2009 13:03:22 +0000, Lorenz did cat*: [...] > >>> Well yes indeed but it may show you may have missed the > >>>"let's play 'flog' for a change ;-)" part? > > >>that may be (due to lack in knowledge about english proverbs) > > > echo flog |rev > > > Loki's from .fr > > yup, and that'd make me a frog, maybe the reason why > flog's a natural ;-) > Or maybe Lorenz was thinking to that amelican plovelb? > "Can't tell by looking at a flog how high he will jump." > > > > >>Lorenz (allready thinking about a getline version 8-) > > Noooo, get back!-) > > > > > The boggle minds... > > as you requested boggle here's a last and boggling flog, > I promise I won't push any other after that one ;-) > ----------- > awk -v col=3 -v row=5 ' > { > * * * * row-- > * * * * while(++i){ > * * * * * * * * a[++n]=$(i) > * * * * * * * * if($(i)~/[\n]/){ > * * * * * * * * * * * * row-- > * * * * * * * * } > * * * * * * * * if(!row){ > * * * * * * * * * * * * while(++i){ > * * * * * * * * * * * * * * * * a[++n]=$(i) > * * * * * * * * * * * * * * * * if($(i)~/[ \t]/){ > * * * * * * * * * * * * * * * * * * * * col-- > * * * * * * * * * * * * * * * * * * * * if(!col){ > * * * * * * * * * * * * * * * * * * * * * * * * for(p=n-1;p;p--){ > * * * * * * * * * * * * * * * * * * * * * * * * * * * * printf("%s", a[n-p]) > * * * * * * * * * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * * * * * * * * * * * * * printf("%s","\n") > * * * * * * * * * * * * * * * * * * * * * * * * exit > * * * * * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * * * * * * * * * n=0 > * * * * * * * * * * * * * * * * * * * * delete(a) > * * * * * * * * * * * * * * * * } > * * * * * * * * * * * * } > * * * * * * * * } > * * * * }} > > ' RS= FS= yerfile > ----------- awk -v LINE=2 -v COLUMN=5 'NR==LINE {print substr($0, COLUMN, 1)}' |
|
|
|
|
![]() |
| Popular Tags in the Forum |
| column, line, print, xth, yth |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Treedisc Macro | Alex Murphy | Newsgroup comp.soft-sys.sas | 0 | 04-28-2009 08:04 AM |
| client-server socket script that crashes on Mac | Bad Mutha Hubbard | Newsgroup comp.lang.python | 0 | 04-16-2009 02:35 AM |
| Windows command line not displaying print commands | JonathanB | Newsgroup comp.lang.python | 8 | 03-31-2009 02:59 PM |
| PROC REPORT and LINE statement | Tom Hide | Newsgroup comp.soft-sys.sas | 0 | 08-03-2005 07:39 PM |
| Re: Solution: PROC REPORT and LINE statement | Tom Hide | Newsgroup comp.soft-sys.sas | 0 | 08-01-2005 08:52 AM |