How can I split a file based on a search pattern and the new files that will be generated will have the file names as equal to the search pattern which was used to split the fil
Try:
awk '/^GROUP[0-9]+$/{x=$0;next}{print > x;}' cdw_all_jobs_reduced3.txt
If you want the "filenames" remove next statement:
awk '/^GROUP[0-9]+$/{x=$0}{print > x;}' cdw_all_jobs_reduced3.txt
Just a note to people that might have a large number of files that have to be generated. Your command will crash unless you close the previously generated file first, so the improved version of Juan Diego Godoy
's answer would be:
awk '/^GROUP[0-9]+$/{close(x);x=$0}{print > x;}' cdw_all_jobs_reduced3.txt