Too many open files error while running awk comman

2020-03-12 02:41发布

I am trying to split a big file based on a pattern. I am using awk command for this. After creating certain number of files it gives error: Too many open files.

Command is:

awk '/pattern here/{i++}{print > "file"i}' /input file

Can someone tell me how to close these files? I tried following but it gives error.

    awk '/pattern here/{i++}{print > "file"i}' /input file | close("file"i)

标签: linux shell awk
1条回答
叛逆
2楼-- · 2020-03-12 03:36

Before starting on the next file, close the previous one:

awk '/pattern here/{close("file"i); i++}{print > "file"i}' InputFile
查看更多
登录 后发表回答