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: david kerns
Subject: Re: [bug-gawk] Is there a way to get the current file number?
Date: Wed, 3 Apr 2019 12:36:02 -0700

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]