[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] How to just read header of files in ARGV?
From: |
Peng Yu |
Subject: |
[bug-gawk] How to just read header of files in ARGV? |
Date: |
Thu, 12 Sep 2019 21:20:31 -0500 |
BEGIN {
for(i=1;i<ARGC;++i) {
getline < ARGV[i]
print i, $0
}
}
{
print FILENAME, $1
}
If I attempt to read file headers in BEGIN, I got the following error.
What is the correct way to peek file headers yet still let awk
automatically read the rest lines of the files? Thanks.
$ awk -v FS='\t' -f .main.awk <(printf '%s\n' h1 {1..3}) <(printf
'%s\n' h2 {11..13}) <(printf '%s\n' h3 {21..23})
1 h1
2 h2
3 h3
awk: warning: close of fd 61 (`/dev/fd/61') failed (Bad file descriptor)
awk: warning: close of fd 62 (`/dev/fd/62') failed (Bad file descriptor)
awk: warning: close of fd 63 (`/dev/fd/63') failed (Bad file descriptor)
--
Regards,
Peng
- [bug-gawk] How to just read header of files in ARGV?,
Peng Yu <=