1

I have many data files to process but it isn’t necessary to process every record in every file.Is there a way to instruct awk to stop precessing the current file and skip to the next file?

Ren
  • 2,852
  • 2
  • 23
  • 45
  • What version of mawk are you using? The version of [mawk](http://invisible-island.net/mawk/) maintained by Thomas Dickey had nextfile added to it on 20120627. – joast Apr 01 '16 at 01:46
  • @joast - The version of `mawk` that I am using is `1.3.3`, it's the newest version on Ubuntu 14.04. – Ren Apr 01 '16 at 02:22
  • 3
    I'm sorry to say that if you are stuck with a version of mawk that is almost 20 years old, then the only option is to process every record in every file unless you install a newer version of mawk, or install gawk, or install any of the other more recent versions of awk. – joast Apr 01 '16 at 22:04
  • @joast sometimes I kinda need that type of beratement to get me to install a new tool. `gawk` seems pretty worth it. – Nathan Chappell Nov 04 '20 at 12:37

1 Answers1

1

you can use nextfile statement, it's supported in many awks (except perhaps Solaris)

$ awk '/4/{nextfile} 1' <(seq 10) <(seq 10)
1
2
3
1
2
3
karakfa
  • 66,216
  • 7
  • 41
  • 56
  • Thanks for your answer, but I'm using `mawk`, it does not support `nextfile` statement. – Ren Apr 01 '16 at 01:29