bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Is there a way to get the current file number?


From: arnold
Subject: Re: [bug-gawk] Is there a way to get the current file number?
Date: Tue, 09 Apr 2019 07:42:16 -0600
User-agent: Heirloom mailx 12.5 7/5/10

David's answer is clean and portable. There is also gawk's ARGIND
variable. See the manual.

Thanks,

Arnold

david kerns <address@hidden> wrote:

> using your same example:
> $ awk 'FNR==1 {filenumber++} { print FILENAME, filenumber, $0 }' /tmp/1.txt
> /tmp/1.txt /tmp/1.txt
> /tmp/1.txt 1 1
> /tmp/1.txt 2 1
> /tmp/1.txt 3 1
>
>
> On Wed, Apr 3, 2019 at 12:25 PM Peng Yu <address@hidden> wrote:
>
> > Hi,
> >
> > FILENAME only gives the filename. Is there a way to get the file number?
> > Thanks.
> >
> > $ echo 1 > /tmp/1.txt
> > $ awk -e '{ print FILENAME, $0 }' /tmp/1.txt  /tmp/1.txt
> > /tmp/1.txt 1
> > /tmp/1.txt 1
> >
> > --
> > Regards,
> > Peng
> >
> >



reply via email to

[Prev in Thread] Current Thread [Next in Thread]