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)
The "Too many open files" message means that the operating system has reached the maximum "open files" limit and will not allow SecureTransport, or any other running applications to open any more files. The open file limit can be viewed with the ulimit command: The ulimit -aS command displays the current limit.
awk '{ print $2; }' prints the second field of each line. This field happens to be the process ID from the ps aux output. xargs kill -${2:-'TERM'} takes the process IDs from the selected sidekiq processes and feeds them as arguments to a kill command.
Before starting on the next file, close the previous one:
awk '/pattern here/{close("file"i); i++}{print > "file"i}' InputFile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With